/* ==========================================================================
   Plán – timeline of a scenario (docs/SPEC_PLAN.md §3, views/plan.js)
   All classes are prefixed .pl-. Mobile first: the base rules are the phone layout (360–400 px),
   wider screens are added with min-width queries. Colours only through app.css tokens; the lane
   colour of an element comes from charts.js seriesColor() as the custom property --pl-c.
   ========================================================================== */

.pl { min-width: 0; }
.pl-screen, .pl-content { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pl-print { display: none; }
.pl-head { margin-bottom: 0; }
.pl-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pl-head-actions .btn { height: 40px; }
/* Phones: the three actions stay on one row – "Tlačiť plán" shrinks to its icon (it keeps its
   accessible name). */
@media (max-width: 480px) {
  .pl-head-actions .btn { padding-inline: 11px; }
  .pl-print-btn.btn { width: 40px; padding: 0; border-color: var(--border-strong); }
  .pl-print-btn > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

.pl-dot {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pl-c, var(--muted));
}
.pl-chevron { display: inline-flex; flex: none; margin-left: auto; color: var(--text-2); transition: transform 0.15s; }
[aria-expanded="true"] > .pl-chevron,
[aria-expanded="true"] > .pl-y-line > .pl-chevron { transform: rotate(180deg); }

/* ---------- Strip: period, counts, lowest cash, view switch ---------- */
.pl-strip { display: flex; flex-direction: column; gap: 14px; padding: 14px 16px; }
.pl-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.pl-stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
/* Phones: the period is one quiet line above the two figures that matter. */
.pl-stat[data-stat="period"] { grid-column: 1 / -1; flex-flow: row wrap; align-items: baseline; gap: 2px 8px; }
.pl-stat[data-stat="period"] .pl-stat-value { font-size: 14px; }
.pl-stat-label { font-size: 12px; color: var(--text-2); }
.pl-stat-main { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pl-stat-icon { display: inline-flex; color: var(--critical-text); }
.pl-stat-value { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pl-stat-sub { font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; }
.pl-stat--neg .pl-stat-value, .pl-stat--neg .pl-stat-sub { color: var(--critical-text); }

.pl-controls { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 20px; padding-top: 14px; border-top: 1px solid var(--border); }
.pl-view-switch { display: flex; flex: 1 1 100%; }
.pl-view-switch .segmented-item { flex: 1 1 0; justify-content: center; height: 40px; }
.pl-smooth { flex: 1 1 260px; min-width: 0; }
.pl-smooth-toggle { min-height: 40px; }
.pl-smooth-hint { margin: 4px 0 0; }

/* ---------- Typical month ---------- */
.pl-typical { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.pl-typ {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.pl-typ-title { grid-column: 1 / -1; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.pl-typ-cell { display: flex; flex-direction: column; min-width: 0; }
.pl-typ-label { font-size: 11.5px; color: var(--text-2); }
.pl-typ-value { font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pl-typ-net.is-negative .pl-typ-value { color: var(--critical-text); }

/* ---------- Legend ---------- */
.pl-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); }
.pl-legend-item { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Backlog: "Ešte nezaradené" ---------- */
.pl-backlog-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius-lg);
  background: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  text-align: left;
}
.pl-backlog-count {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning-text);
  font-size: 12.5px;
  font-weight: 650;
}
.pl-backlog-count.is-zero { background: var(--surface-2); color: var(--text-2); }
.pl-backlog-body { display: flex; flex-direction: column; gap: 12px; padding: 0 16px 16px; min-width: 0; }
.pl-backlog-list { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pl-bl-lane { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.pl-bl-rows { display: flex; flex-direction: column; gap: 6px; }
.pl-bl-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 8px 10px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.pl-bl-text { display: flex; flex: 1 1 180px; flex-direction: column; min-width: 0; }
.pl-bl-name { font-weight: 600; overflow-wrap: anywhere; }
.pl-bl-note { font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; }
.pl-bl-add { flex: 1 1 100%; height: 40px; }
.pl-bl-none { margin: 0; }
.pl-backlog-new { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.pl-bl-new-label { flex: 1 1 100%; font-size: 12.5px; color: var(--text-2); }
.pl-bl-new-link { height: 40px; text-decoration: none; }
.pl-bl-new-link:hover { text-decoration: none; }

/* ---------- Kalendár ---------- */
.pl-cal { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pl-cal-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.pl-cal-bar-text { min-width: 0; }
.pl-cal-all.btn { flex: none; height: 40px; }
.pl-cal-all.is-all .icon { transform: rotate(180deg); }
.pl-cal-years { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.pl-year {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  scroll-margin-top: calc(var(--header-h) + 8px);
}
.pl-year--neg { border-left: 3px solid var(--critical); }
/* Phones: only the header button sticks (.pl-y-top generates no box, so the button sticks within
   the whole year); wide screens: header + totals stick together. */
.pl-y-top { display: contents; }
.pl-y-head {
  position: sticky;
  top: var(--header-h);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.pl-year.is-open > .pl-y-top > .pl-y-head { border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: 0 1px 0 var(--border); }
.pl-y-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pl-y-line > .pl-chevron { margin-left: 0; }
.pl-y-title { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.pl-y-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--critical-soft);
  color: var(--critical-text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pl-y-netwrap { display: flex; align-items: baseline; gap: 6px; margin-left: auto; white-space: nowrap; }
/* Phones: the "pod nulou" flag is only its icon (the totals line under the header says it in words). */
@media (max-width: 480px) {
  .pl-y-flag { padding: 3px; }
  .pl-y-flag > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
.pl-y-netlabel { font-size: 12px; color: var(--text-2); }
.pl-y-net { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.pl-y-net.is-negative { color: var(--critical-text); }
.pl-y-avg, .pl-y-cash { font-size: 12.5px; color: var(--text-2); }
/* The sticky year header stays one line + one line: the averages never wrap to a third line that
   would hide the name of the month scrolled under it. */
.pl-y-avg { display: block; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-y-cash { display: none; }
.pl-y-cash.is-negative { color: var(--critical-text); font-weight: 600; }
.pl-y-totals { margin: 0; padding: 8px 14px 10px; font-size: 12.5px; color: var(--text-2); }
.pl-year--neg .pl-y-totals { color: var(--critical-text); }
.pl-cal-cols { display: none; }
.pl-months { display: flex; flex-direction: column; }

/* A month that the app scrolls to stops below the app header and the sticky year header. */
.pl-month { border-top: 1px solid var(--border); min-width: 0; scroll-margin-top: calc(var(--header-h) + 72px); }
.pl-month--neg { box-shadow: inset 3px 0 0 var(--critical); }
.pl-month.is-open { background: var(--surface-2); }
.pl-m-row { display: flex; align-items: stretch; min-width: 0; }
.pl-m-toggle {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-areas: "name name net net" "inc cost debt cash";
  gap: 6px 8px;
  min-width: 0;
  padding: 10px 4px 10px 14px;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
}
.pl--readonly .pl-m-toggle { padding-right: 14px; }
.pl-m-name { grid-area: name; align-self: center; font-size: 15px; font-weight: 650; }
.pl-m-cell { display: flex; flex-direction: column; min-width: 0; }
.pl-m-label { font-size: 10.5px; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-2); }
.pl-m-value { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pl-m-inc { grid-area: inc; }
.pl-m-cost { grid-area: cost; }
.pl-m-debt { grid-area: debt; }
.pl-m-net { grid-area: net; flex-direction: row; align-items: baseline; justify-content: flex-end; gap: 6px; }
.pl-m-net .pl-m-label { font-size: 12px; letter-spacing: 0; text-transform: none; }
.pl-m-net .pl-m-value { font-size: 16px; font-weight: 700; }
.pl-m-cash { grid-area: cash; display: grid; grid-template-columns: auto auto; justify-content: end; column-gap: 4px; }
.pl-m-cash .pl-m-label { grid-column: 1 / -1; text-align: right; }
.pl-m-warn { display: inline-flex; align-self: center; color: var(--critical-text); }
.pl-m-cell.is-negative .pl-m-value, .pl-m-cell.is-negative .pl-m-label { color: var(--critical-text); }
.pl-m-cash.is-negative .pl-m-value { font-weight: 650; }
/* Separate finances on a phone: the cash column is narrow, so "Hotovosť farmy" and "komunita …" wrap
   inside it instead of spilling over the Splátky column (household.css keeps them on one line). */
@media (max-width: 899px) {
  .pl-m-toggle .pl-m-cash .pl-m-comm { white-space: normal; }
  .pl-m-toggle .pl-m-cash .pl-m-label { overflow-wrap: anywhere; }
}
.pl-m-add.btn { flex: none; align-self: stretch; width: 44px; height: auto; min-height: 44px; border-radius: 0; color: var(--link); }
.pl-m-once { margin: 0; padding: 0 14px 8px; font-size: 12.5px; color: var(--text-2); }
.pl-m-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; min-width: 0; }

.pl-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 4px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  text-align: left;
}
.pl-chip:hover { background: var(--surface-3); }
.pl-chip-flag { display: inline-flex; flex: none; color: var(--pl-c, var(--text-2)); }
.pl-chip-tag { flex: none; font-size: 10.5px; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-2); }
.pl-chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.pl-chip-link { flex: none; color: var(--link); }
.pl-chip-amount { flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-2); }
.pl-chip-amount:empty { display: none; }
.pl-chip.is-in .pl-chip-amount { color: var(--good-text); }
.pl-chip.is-end { background: var(--surface-2); }
.pl-chip.is-inactive { border-style: dashed; opacity: 0.65; }
.pl-chip.is-done .pl-chip-name { text-decoration: line-through; color: var(--text-2); }
.pl-chip--group { border-style: dashed; color: var(--text-2); }
.pl-chip--group .pl-dot { display: none; }

.pl-m-detail-inner { display: flex; flex-direction: column; gap: 12px; padding: 2px 14px 14px; }
.pl-bd { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.pl-bd-group { min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.pl-bd-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; font-size: 13px; font-weight: 650; }
.pl-bd-line { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; font-size: 13px; }
.pl-bd-name { min-width: 0; overflow-wrap: anywhere; color: var(--text-2); }
.pl-bd-line.strong .pl-bd-name { color: var(--text); }
.pl-bd-value { flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pl-bd-note { margin: 0; }
.pl-bd-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pl-bd-actions .btn { flex: 1 1 140px; height: 44px; }

/* ---------- Pruhy (Gantt) ---------- */
.pl-gantt { min-width: 0; }
.pl-g-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; }
.pl-g-bar .segmented-item { height: 40px; }
.pl-g-hint { flex: 1 1 220px; min-width: 0; }
.pl-g-card { position: relative; overflow: hidden; }
.pl-g-scroll { overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; outline-offset: -2px; }
.pl-g-inner { --pl-name-w: 124px; position: relative; width: calc(var(--pl-name-w) + var(--pl-track, 0px)); min-width: 100%; }
.pl-g-row { display: flex; min-height: 44px; border-bottom: 1px solid var(--border); }
.pl-g-name {
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  flex: 0 0 var(--pl-name-w);
  align-items: center;
  gap: 6px;
  width: var(--pl-name-w);
  min-width: 0;
  padding: 0 8px;
  border: 0;
  border-right: 1px solid var(--border-strong);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  text-align: left;
}
.pl-g-entry:hover { background: var(--surface-3); }
.pl-g-nametext, .pl-g-lanelabel { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-g-link { flex: none; color: var(--link); }
.pl-g-track {
  position: relative;
  flex: 0 0 var(--pl-track, 0px);
  width: var(--pl-track, 0px);
  background-image: linear-gradient(to right, var(--axis) 1px, transparent 1px);
  background-position: var(--pl-year-shift, 0px) 0;
  background-size: calc(var(--pl-ppm, 18px) * 12) 100%;
}
[data-zoom="month"] .pl-g-track {
  background-image: linear-gradient(to right, var(--axis) 1px, transparent 1px), linear-gradient(to right, var(--grid) 1px, transparent 1px);
  background-position: var(--pl-year-shift, 0px) 0, 0 0;
  background-size: calc(var(--pl-ppm, 60px) * 12) 100%, var(--pl-ppm, 60px) 100%;
}
.pl-g-head { min-height: 0; }
.pl-g-corner { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); }
.pl-g-inner .pl-g-axis { height: 44px; background-color: var(--surface-2); background-image: none; }
.pl-g-inner[data-zoom="year"] .pl-g-axis { height: 26px; }
.pl-g-year, .pl-g-tick { position: absolute; overflow: hidden; white-space: nowrap; }
.pl-g-year { top: 0; height: 24px; padding: 3px 0 0 5px; border-left: 1px solid var(--axis); font-size: 12.5px; font-weight: 650; }
.pl-g-tick { top: 24px; height: 20px; border-left: 1px solid var(--grid); font-size: 11px; color: var(--text-2); text-align: center; }
.pl-g-lanehead { min-height: 44px; }
.pl-g-lanehead .pl-g-track, .pl-g-lanebtn { background-color: var(--surface-2); }
/* The lane title may run over its (empty) track instead of being cut on a phone. */
.pl-g-lanebtn { overflow: visible; border-right-color: transparent; font-weight: 650; white-space: nowrap; }
.pl-g-lanebtn .pl-g-lanelabel { flex: none; overflow: visible; }
.pl-g-lanecount { flex: none; font-size: 12px; font-weight: 500; color: var(--text-2); }
.pl-g-lanebtn .pl-chevron { margin-left: 2px; }

.pl-bar {
  position: absolute;
  top: 50%;
  height: 24px;
  margin-top: -12px;
  border: 1.5px solid var(--pl-c, var(--muted));
  border-radius: 6px;
  background: var(--surface-2);
  background: color-mix(in srgb, var(--pl-c, var(--muted)) 26%, var(--surface));
  color: var(--text);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.pl-bar.is-movable { cursor: grab; }
.pl-bar.is-oneoff { width: 14px; height: 14px; margin-top: -7px; border: 2px solid var(--surface); border-radius: 50%; background: var(--pl-c, var(--muted)); box-shadow: 0 0 0 1px var(--pl-c, var(--muted)); }
/* A larger hit area for a 14 px mark and a 24 px bar. */
.pl-bar.is-oneoff::before { content: ""; position: absolute; inset: -14px; }
.pl-bar.is-range::before { content: ""; position: absolute; inset: -10px 0; }
.pl-bar.is-flag { border-radius: 2px; transform: rotate(45deg); }
.pl-bar.is-open { border-right-color: transparent; border-radius: 6px 0 0 6px; }
.pl-bar.is-open::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  bottom: -2px;
  width: 44px;
  background: linear-gradient(to right, transparent, var(--surface));
  pointer-events: none;
}
.pl-bar.is-linked.is-range { border-style: dashed; }
.pl-bar.is-inactive { opacity: 0.5; }
.pl-bar.is-done { opacity: 0.6; }
.pl-bar.is-dragging { z-index: 4; cursor: grabbing; box-shadow: var(--shadow); }
.pl-gantt.is-dragging { cursor: grabbing; -webkit-user-select: none; user-select: none; }
.pl-bar-label { display: block; padding: 0 8px; overflow: hidden; font-size: 12px; line-height: 21px; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.pl-bar-end {
  position: absolute;
  top: -1.5px;
  right: -1.5px;
  bottom: -1.5px;
  z-index: 1;
  width: 16px;
  border-radius: 0 6px 6px 0;
  background: var(--pl-c, var(--muted));
  cursor: ew-resize;
  opacity: 0.55;
}
.pl-bar-side { position: absolute; top: 50%; margin-top: -9px; font-size: 12px; line-height: 18px; color: var(--text-2); white-space: nowrap; pointer-events: none; }

.pl-g-budget { border-top: 2px solid var(--border-strong); }
.pl-g-budgetrow { min-height: 34px; }
.pl-g-budgetname, .pl-g-cashname { font-weight: 600; background: var(--surface-2); }
.pl-g-cell {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pl-g-inner:not([data-zoom="month"]) .pl-g-budgetrow { min-height: 46px; }
.pl-g-inner:not([data-zoom="month"]) .pl-g-cell { justify-content: flex-end; padding-bottom: 3px; }
.pl-g-mini { flex: none; width: min(60%, 26px); border-radius: 2px 2px 0 0; background: var(--muted); }
.pl-g-cell.is-negative { color: var(--critical-text); }
.pl-g-cell.is-negative .pl-g-mini { background: var(--critical); }
.pl-g-cash { min-height: 72px; border-bottom: 0; }
.pl-cash-svg { display: block; max-width: none; }
.pl-cash-line { stroke-width: 2; stroke-linejoin: round; }
.pl-cash-area { opacity: 0.12; stroke: none; }
.pl-cash-zero { stroke: var(--axis); stroke-dasharray: 3 3; stroke-width: 1; }
.pl-cash-neg { fill: var(--critical-soft); }
.pl-cash-hit { fill: transparent; }
.pl-g-tip {
  position: absolute;
  z-index: 6;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-size: 12.5px;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -100%);
}

/* ---------- Sheets (modal() with className pl-sheet) ---------- */
.pl-sh { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pl-sh-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; color: var(--text-2); outline: none; }
.pl-sh-sentence, .pl-sh-when, .pl-sh-follow, .pl-sh-note, .pl-sh-diff, .pl-shift-preview { margin: 0; }
.pl-sh-when { font-size: 15px; font-weight: 650; }
.pl-sh-reason:empty, .pl-sh-live:empty { display: none; }
.pl-sh .month-input .input { height: 46px; font-size: 16px; }
.pl-quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.pl-quick-btn.btn { height: 46px; padding: 0 4px; font-size: 14px; }
.pl-sh .segmented { display: flex; }
.pl-sh .segmented-item { flex: 1 1 0; justify-content: center; height: 44px; }
.pl-sh-live { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); }
.pl-sh-fig { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 13px; }
.pl-sh-figlabel { min-width: 0; color: var(--text-2); }
.pl-sh-figvalue { display: inline-flex; flex: none; align-items: center; gap: 4px; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pl-sh-diff { font-size: 12.5px; }
.pl-sh-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pl-sh-actions .btn { flex: 1 1 180px; height: 44px; }
.pl-pick-list { display: flex; flex-direction: column; gap: 6px; }
.pl-pick-list .pl-bl-lane { margin: 6px 0 0; }
.pl-pick {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name icon" "note icon";
  align-items: center;
  gap: 0 10px;
  min-height: 52px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.pl-pick:hover { background: var(--surface-3); }
.pl-pick-name { grid-area: name; font-weight: 600; overflow-wrap: anywhere; }
.pl-pick-note { grid-area: note; font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; }
.pl-pick-note:empty { display: none; }
.pl-pick > .icon { grid-area: icon; color: var(--link); }

/* Phones: the sheets come up from the bottom edge, full width, with a grab handle. */
@media (max-width: 560px) {
  .modal.pl-sheet {
    width: calc(100% + 24px);
    max-width: none;
    max-height: calc(100vh - 28px);
    margin: 0 -12px -12px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    animation: pl-sheet-in 0.2s ease-out;
  }
  .modal.pl-sheet::before { content: ""; flex: none; width: 36px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--border-strong); }
  .pl-sheet .modal-header { padding-top: 10px; }
  .pl-sheet .modal-footer .btn { height: 46px; }
}
@supports (height: 100dvh) {
  @media (max-width: 560px) {
    .modal.pl-sheet { max-height: calc(100dvh - 28px); }
  }
}
@keyframes pl-sheet-in { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .modal.pl-sheet { animation: none; }
}

/* ---------- Wider screens ---------- */
@media (min-width: 640px) {
  .pl-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pl-stat[data-stat="period"] { grid-column: auto; flex-flow: column nowrap; align-items: stretch; gap: 1px; }
  .pl-stat[data-stat="period"] .pl-stat-value { font-size: 17px; }
  .pl-view-switch { flex: 0 0 auto; }
  .pl-view-switch .segmented-item { flex: 0 0 auto; padding: 0 16px; }
  .pl-typ-value { font-size: 14.5px; }
  .pl-bl-add { flex: none; }
  .pl-bl-new-label { flex: none; }
  .pl-bd { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pl-bd--sum, .pl-bd-note { grid-column: 1 / -1; }
  .pl-bd-actions .btn { flex: none; }
  .pl-g-inner { --pl-name-w: 200px; }
  .pl-g-name { padding: 0 12px; }
}
@media (min-width: 900px) {
  .pl-typical { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Month rows become one table-like line under a column header. */
  .pl-cal-cols, .pl-m-toggle { grid-template-columns: 130px repeat(5, minmax(0, 1fr)); grid-template-areas: "name inc cost debt net cash"; }
  .pl-cal-cols {
    display: grid;
    gap: 8px;
    padding: 8px 48px 8px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    text-align: right;
  }
  .pl--readonly .pl-cal-cols { padding-right: 14px; }
  .pl-cal-cols > :first-child { text-align: left; }
  .pl-m-toggle { align-items: center; padding-block: 8px; }
  .pl-m-toggle:hover { background: var(--surface-2); }
  .pl-m-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .pl-m-cell { position: relative; align-items: flex-end; }
  .pl-m-value { font-size: 14px; }
  .pl-m-net .pl-m-value { font-size: 14.5px; }
  .pl-m-cash.is-negative .pl-m-label { position: static; width: auto; height: auto; clip-path: none; }
  /* Room enough: the totals of the year stay in view together with the year header. */
  .pl-y-top { display: block; position: sticky; top: var(--header-h); z-index: 5; background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .pl-y-head { position: static; }
  .pl-year.is-open > .pl-y-top > .pl-y-head { box-shadow: none; }
  .pl-year.is-open > .pl-y-top { box-shadow: 0 1px 0 var(--border); }
  .pl-y-totals { padding-top: 0; }
  .pl-y-cash { display: inline; }
  .pl-y-tot-cash { display: none; }
}
@media (pointer: fine) and (min-width: 640px) {
  .pl-g-row, .pl-g-lanehead { min-height: 36px; }
  .pl-g-bar .segmented-item { height: 30px; }
  .pl-chip { min-height: 34px; }
  .pl-bar-end { width: 10px; opacity: 0; }
  .pl-bar:hover .pl-bar-end, .pl-bar:focus-visible .pl-bar-end, .pl-bar.is-dragging .pl-bar-end { opacity: 0.8; }
}

/* ---------- Dotácie (subsidies module): payment month markers ---------- */
.pl-m-sub { display: flex; align-items: flex-start; gap: 6px; margin: 0; padding: 0 14px 8px; font-size: 12.5px; color: var(--text-2); }
.pl-m-sub > .icon { flex: none; margin-top: 2px; }
.pl-m-sub-text { min-width: 0; overflow-wrap: anywhere; }
.pl-bd--sub { grid-column: 1 / -1; }
.pl-bd-subnote { margin: 4px 0 0; }
.pl-bd-sublink { display: inline-flex; align-items: center; min-height: 40px; font-size: 13px; }
.pl-g-subrow { min-height: 36px; }
.pl-g-subname { font-weight: 600; background: var(--surface-2); }
.pl-g-subpay { display: contents; }
.pl-g-submark {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border: 2px solid var(--pl-c, var(--muted));
  border-radius: 2px;
  background: var(--surface);
  transform: rotate(45deg);
}

/* ---------- Reprodukčný plánovač (docs/SPEC_HERD.md §3): months in which a herd sells animals ---------- */
.pl-m-herd { display: flex; align-items: flex-start; gap: 6px; margin: 0; padding: 0 14px 8px; font-size: 12.5px; color: var(--text-2); }
.pl-m-herd > .icon { flex: none; margin-top: 2px; }
.pl-bd--herd { grid-column: 1 / -1; }
.pl-g-herdrow { min-height: 36px; }
.pl-g-herdmark { border-radius: 50%; transform: none; }

/* ---------- Print: a clean chronological list ---------- */
@media print {
  .pl-screen { display: none !important; }
  .pl-print { display: block; }
  .pl-print h2 { margin: 0 0 4px; font-size: 16pt; }
  .pl-print h3 { margin: 14px 0 2px; font-size: 12pt; break-after: avoid; }
  .pl-print p { margin: 0 0 6px; font-size: 9.5pt; }
  .pl-pr-note { color: var(--text-2); }
  .pl-pr-table { width: 100%; border-collapse: collapse; font-size: 8.5pt; font-variant-numeric: tabular-nums; }
  .pl-pr-table th, .pl-pr-table td { padding: 2px 5px; border-bottom: 1px solid var(--border-strong); text-align: right; vertical-align: top; white-space: nowrap; }
  .pl-pr-table th:first-child, .pl-pr-table td.pl-pr-items, .pl-pr-table th:last-child { text-align: left; }
  .pl-pr-table td.pl-pr-items { width: 42%; white-space: normal; }
  .pl-pr-table tr { break-inside: avoid; }
  .pl-pr-table tr.is-negative td, .pl-pr-table tr.is-negative th { color: var(--critical-text); }
}

/* ==========================================================================
   Plánovanie (docs/SPEC_PLANNING_NOTES.md §2): Úlohy view, task chips in Kalendár,
   the "Otvorené úlohy" stat, dimmed 'Zrušené' entries. The panel itself is planning.css (.pln-).
   ========================================================================== */

.pl-stat[data-stat="tasks"] { grid-column: 1 / -1; flex-flow: row wrap; align-items: baseline; gap: 2px 8px; }
.pl-stat--overdue .pl-stat-sub { color: var(--critical-text); font-weight: 600; }
@media (min-width: 640px) {
  .pl-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pl-stat[data-stat="tasks"] { grid-column: auto; flex-flow: column nowrap; align-items: stretch; gap: 1px; }
}

/* 'Zrušené' entries (planning status) are dimmed on the timeline */
.pl-chip.is-dropped, .pl-bar.is-dropped { opacity: 0.45; }
.pl-chip.is-dropped .pl-chip-name { text-decoration: line-through; }

/* Kalendár: tasks and due dates of a month */
.pl-m-tasks { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; min-width: 0; }
.pl-tchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 4px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  text-align: left;
}
.pl-tchip:hover { background: var(--surface-3); }
.pl-tchip-icon { display: inline-flex; flex: none; color: var(--text-2); }
.pl-tchip-main { display: flex; flex-direction: column; min-width: 0; }
.pl-tchip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.pl-tchip-entry { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--text-2); }
.pl-tchip-date { flex: none; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pl-tchip.is-due { border-style: solid; }
.pl-tchip.is-overdue { border-color: var(--critical); background: var(--critical-soft); }
.pl-tchip.is-overdue .pl-tchip-icon, .pl-tchip.is-overdue .pl-tchip-date { color: var(--critical-text); font-weight: 600; }
.pl-tchip.is-done .pl-tchip-text { text-decoration: line-through; color: var(--text-2); }
.pl-tchip.is-done .pl-tchip-icon { color: var(--good-text); }
.pl-tchip.is-dropped { opacity: 0.5; }

/* Úlohy view */
.pl-tasks { display: flex; flex-direction: column; gap: 12px; min-width: 0; scroll-margin-top: calc(var(--header-h, 56px) + 8px); }
.pl-tasks[hidden] { display: none; }
.pl-t-filters { padding: 0; }
.pl-t-fhead {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 8px 14px;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.pl-t-fhead.is-open .pl-chevron { transform: rotate(180deg); }
.pl-t-fcount:not(:empty) { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--link); font-size: 12px; line-height: 20px; text-align: center; }
.pl-t-fbody { display: flex; flex-direction: column; gap: 10px; padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.pl-t-fbody[hidden] { display: none; }
.pl-t-frow { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding-top: 8px; }
.pl-t-frow[hidden] { display: none; }
.pl-t-flabel { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.pl-t-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pl-t-who { max-width: 280px; }
.pl-t-reset { align-self: flex-start; }
.pl-t-reset[hidden] { display: none; }
.pl-t-new { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.pl-t-new .field { margin: 0; min-width: 0; }
.pl-t-title { margin: 0; font-size: 15px; font-weight: 650; }
.pl-t-newrow { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.pl-t-newrow .field { flex: 1 1 160px; }
.pl-t-add { flex: 1 1 140px; height: 40px; }
.pl-t-groups { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pl-t-group { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.pl-t-ghead {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  text-align: left;
}
.pl-t-ghead--toggle { cursor: pointer; }
.pl-t-ghead--toggle.is-open .pl-chevron { transform: rotate(180deg); }
.pl-t-gcount { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.pl-t-group--overdue { border-color: var(--critical); }
.pl-t-group--overdue > .pl-t-ghead { background: var(--critical-soft); color: var(--critical-text); }
.pl-t-list { margin: 0; padding: 0; list-style: none; }
.pl-t-list[hidden] { display: none; }
.pl-t-item { display: flex; align-items: flex-start; gap: 4px; min-width: 0; padding: 2px 8px 2px 4px; border-top: 1px solid var(--border); }
.pl-t-item:first-child { border-top: 0; }
.pl-t-checkwrap, .pl-t-dueicon { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 40px; height: 44px; color: var(--text-2); cursor: pointer; }
.pl-t-checkwrap[hidden], .pl-t-dueicon[hidden] { display: none; }
.pl-t-dueicon { cursor: default; }
.pl-t-open {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.pl-t-open:hover .pl-t-text { text-decoration: underline; }
.pl-t-text { font-size: 14.5px; font-weight: 550; overflow-wrap: anywhere; }
.pl-t-sub { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12.5px; color: var(--text-2); min-width: 0; }
.pl-t-meta { overflow-wrap: anywhere; }
.pl-t-when { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.pl-t-when[hidden] { display: none; }
.pl-t-when.is-overdue { color: var(--critical-text); font-weight: 600; }
.pl-t-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.pl-t-tags[hidden] { display: none; }
.pl-t-item.is-done .pl-t-text { text-decoration: line-through; color: var(--text-2); }
.pl-t-item.is-dropped { opacity: 0.55; }
.pl-t-empty[hidden] { display: none; }

/* sheets with the planning panel */
.pl-sh-plan { margin-top: 4px; }
.pl-sh--planning .pl-sh-plan { border: 0; }
.pl-sh--planning .pl-sh-plan > .pln-head { display: none; }
.pl-sh--planning .pl-sh-plan > .pln-body { border-top: 0; padding: 0; }

/* Úlohy filters on touch: ≥ 40 px targets (app-wide .chip is 36 px) */
@media (pointer: coarse) {
  .pl-t-chip { height: 40px; }
  .pl-t-reset { min-height: 40px; }
}
