/* ==========================================================================
   Domov „Dnes“ (views/domov.js, docs/design-v2/Main.dc.html) — prefix .dm-
   Colours only through tokens: the Nova 2 look (v2.css) gives paper #F6F4EE, white cards with a hairline,
   green = farm and income, brown = costs and community; the classic look and dark mode follow app.css.
   Phone first: 16 px gutter of the page, ≥ 44 px targets on touch, nothing wider than the phone.
   ========================================================================== */

.dm { gap: 14px; }

/* Head: date line, greeting, avatar */
.dm-head .v2-head-row { align-items: center; }
.dm-date { font-size: 13px; }
.dm-greet { overflow-wrap: anywhere; }
.dm-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green-text);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.dm-avatar:hover { text-decoration: none; filter: brightness(0.97); }
.dm-avatar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* „Režim farmy“ (R13, end of the page: the first screen stays as in the design) – the badge „Simulácia“ / „Prevádzka od …“,
   the hint and „Spustiť prevádzku“ or the way to the pair (views/operation.js, css/operation.css); no switch back */
.dm-mode {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-width: 0;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.dm-mode[hidden] { display: none; }
.dm-mode-title { flex: 1 0 100%; margin: 0; font-size: 15px; font-weight: 700; }
.dm-mode-badge { flex: none; }
.dm-mode-hint { flex: 1 1 200px; min-width: 0; margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.35; }
.dm-mode-actions { display: flex; flex: 1 0 100%; flex-wrap: wrap; gap: 8px; min-width: 0; }
.dm-mode-actions .btn { white-space: normal; text-align: center; }
.dm-mode-actions[hidden], .dm-mode-actions .btn[hidden] { display: none; }
/* R13 banners at the top (a simulation whose operation runs in a copy; the one-time migration notice) */
.dm-op-banners { margin-top: -2px; }

/* Cards */
.dm-body { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.dm-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.dm-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; }
.dm-card-heading { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dm-card-title { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.3; }
.dm-card-sub { margin: 0; color: var(--text-2); font-size: 13px; }
.dm-card-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--link);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
}
.dm-card-link:hover { text-decoration: underline; }
.dm-card-foot { margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.4; }

/* Tiles */
.dm-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dm-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 14px 14px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.dm-tile:hover { border-color: var(--border-strong); text-decoration: none; }
.dm-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.dm-tile-label, .dm-tile-sub { color: var(--text-2); font-size: 12.5px; line-height: 1.35; overflow-wrap: anywhere; }
.dm-tile-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.dm-tile[data-key="cash"] .dm-tile-value { color: var(--green-text); }
.dm-tile .dm-tile-value.is-negative { color: var(--critical-text); }
.dm-tile-unit { color: var(--text-2); font-size: 14px; font-weight: 500; letter-spacing: 0; }
.dm-tile.is-off .dm-tile-value { color: var(--text-2); }

/* „Dnes na farme“ */
.dm-tasks { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.dm-task {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 56px;
  padding: 4px 10px 4px 2px;
  background: var(--surface-2);
  border-radius: 12px;
}
.dm-task[hidden] { display: none; }
.dm-checkwrap {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dm-checkwrap.is-disabled { cursor: default; }
.dm-check {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin: 0;
  border: 2px solid var(--green);
  border-radius: 50%;
  background: var(--surface);
  cursor: inherit;
}
.dm-task[data-tone="brown"] .dm-check { border-color: var(--brown); }
.dm-task[data-tone="grey"] .dm-check { border-color: var(--grey); }
.dm-check::after {
  content: "";
  width: 6px;
  height: 11px;
  margin-top: -2px;
  border: solid var(--accent-contrast);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 120ms ease-out;
}
.dm-check:checked { background: var(--green); border-color: var(--green); }
.dm-task[data-tone="brown"] .dm-check:checked { background: var(--brown); border-color: var(--brown); }
.dm-task[data-tone="grey"] .dm-check:checked { background: var(--grey-text); border-color: var(--grey-text); }
.dm-check:checked::after { transform: rotate(45deg) scale(1); }
.dm-check:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dm-check:disabled { opacity: 0.55; }
.dm-task-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 6px 0;
  color: var(--text);
  text-decoration: none;
}
.dm-task-body:hover { text-decoration: none; }
.dm-task-body:hover .dm-task-title { text-decoration: underline; }
.dm-task-title, .dm-task-meta {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
/* Long calendar sentences: three lines in the list, the whole text one tap away (the link). */
.dm-task-title { font-weight: 600; line-height: 1.35; -webkit-line-clamp: 3; line-clamp: 3; }
.dm-task-meta { color: var(--text-2); font-size: 13px; line-height: 1.35; -webkit-line-clamp: 2; line-clamp: 2; }
.dm-task.is-done .dm-task-title { color: var(--text-2); text-decoration: line-through; text-decoration-thickness: 1px; }
.dm-who {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green-text);
  font-size: 11.5px;
  font-weight: 700;
}
.dm-who[hidden] { display: none; }
.dm-task-status {
  flex: none;
  max-width: 28%;
  color: var(--text-2);
  font-size: 12.5px;
  text-align: right;
  line-height: 1.3;
}
.dm-task-status[hidden] { display: none; }
.dm-task-status[data-tone="done"] { color: var(--green-text); font-weight: 600; }
.dm-task-status[data-tone="today"] { color: var(--text); font-weight: 600; }
.dm-task-status[data-tone="bad"] { color: var(--critical-text); font-weight: 600; }
/* Planner rows: times, people, work time and the herd or batch – up to three lines */
.dm-task[data-kind="planner"] .dm-task-meta { -webkit-line-clamp: 3; line-clamp: 3; }
/* A task done several times a day (planner: milking 2×) – „hotovo 1/2“: half a ring */
.dm-check:indeterminate { background: linear-gradient(90deg, var(--green) 50%, var(--surface) 50%); }
.dm-task[data-tone="brown"] .dm-check:indeterminate { background: linear-gradient(90deg, var(--brown) 50%, var(--surface) 50%); }
.dm-task[data-tone="grey"] .dm-check:indeterminate { background: linear-gradient(90deg, var(--grey-text) 50%, var(--surface) 50%); }
.dm-today-sub[hidden], .dm-cap[hidden], .dm-energy[hidden] { display: none; }
/* Capacity of today (planner.capacity) */
.dm-cap { color: var(--warning-text); }
.dm-cap[data-tone="bad"] { color: var(--critical-text); }
/* Energy of today on an off-grid farm (planner.energyBudget) → Viac → Energia */
.dm-energy {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.dm-energy:hover { text-decoration: none; }
.dm-energy:hover .dm-energy-title { text-decoration: underline; }
.dm-energy:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dm-energy-icon { flex: none; margin-top: 1px; color: var(--green-text); }
.dm-energy[data-tone="info"] .dm-energy-icon { color: var(--text-2); }
.dm-energy[data-tone="warn"] .dm-energy-icon { color: var(--warning-text); }
.dm-energy[data-tone="bad"] .dm-energy-icon { color: var(--critical-text); }
.dm-energy-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dm-energy-title { font-size: 13.5px; font-weight: 600; }
.dm-energy-text { color: var(--text-2); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.dm-tasks-empty { margin: 0; color: var(--text-2); font-size: 14px; }
.dm-more {
  align-self: flex-start;
  min-height: 36px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--link);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.dm-more[hidden] { display: none; }

/* Alerts: cash, deadline, check (design: amber card with an icon) */
.dm-alerts { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dm-alerts[hidden] { display: none; }
.dm-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  padding: 14px 16px;
  background: var(--warning-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.dm-alert[hidden] { display: none; }
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .dm-alert { border-color: color-mix(in srgb, var(--warning) 38%, var(--warning-soft)); }
  .dm-alert[data-tone="critical"] { border-color: color-mix(in srgb, var(--critical) 32%, var(--critical-soft)); }
  .dm-alert[data-tone="info"] { border-color: var(--border); }
}
.dm-alert-icon { flex: none; margin-top: 1px; color: var(--warning-text); }
.dm-alert-body { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
.dm-alert-title { color: var(--warning-text); font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.dm-alert-text { color: var(--text-2); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.dm-alert-text[hidden], .dm-alert-actions[hidden] { display: none; }
.dm-alert-actions { display: flex; flex-wrap: wrap; gap: 0 16px; }
.dm-alert-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--link);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.dm-alert-link:hover { text-decoration: underline; }
.dm-alert[data-tone="critical"] { background: var(--critical-soft); }
.dm-alert[data-tone="critical"] .dm-alert-icon,
.dm-alert[data-tone="critical"] .dm-alert-title { color: var(--critical-text); }
.dm-alert[data-tone="info"] { background: var(--surface); }
.dm-alert[data-tone="info"] .dm-alert-icon,
.dm-alert[data-tone="info"] .dm-alert-title { color: var(--text); }

/* „Tento mesiac“ */
.dm-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.dm-stats[hidden] { display: none; }
.dm-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dm-stat-label { color: var(--text-2); font-size: 12px; }
.dm-stat-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dm-stat[data-key="income"] .dm-stat-value { color: var(--green-text); }
.dm-stat[data-key="cost"] .dm-stat-value { color: var(--brown-text); }
.dm-stat .dm-stat-value.is-negative { color: var(--critical-text); }
.dm-bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--grid); }
.dm-bar[hidden], .dm-bar-text[hidden], .dm-month-note[hidden], .dm-month-error[hidden] { display: none; }
.dm-bar-fill { width: 0; height: 100%; border-radius: 999px; background: var(--green); transition: width 200ms ease-out; }
.dm-bar.is-over .dm-bar-fill { background: var(--brown); }
.dm-bar-text { margin: -4px 0 0; color: var(--text-2); font-size: 12.5px; }
.dm-month-error { margin: 0; color: var(--critical-text); font-size: 14px; }
.dm-links { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 2px; }
.dm-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
}
.dm-link:hover { border-color: var(--border-strong); text-decoration: none; }
.dm-link .v2-icon { color: var(--text-2); }

/* Empty scenario */
.dm-empty { align-items: flex-start; }
.dm-empty[hidden] { display: none; }
.dm-empty-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--green-soft); color: var(--green-text); }
.dm-empty-text { margin: 0; color: var(--text-2); }
.dm-empty-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* Wider screens: tiles and the two cards side by side */
@media (min-width: 900px) {
  .dm-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "tiles tiles" "today alerts" "today month";
    grid-template-rows: auto auto 1fr;
    align-items: start;
  }
  .dm-tiles { grid-area: tiles; }
  .dm-alerts { grid-area: alerts; }
  .dm-today { grid-area: today; }
  .dm-month { grid-area: month; }
}

/* Touch: ≥ 44 px targets */
@media (pointer: coarse) {
  .dm-mode-actions .btn { min-height: 44px; }
  .dm-card-link, .dm-more, .dm-alert-link, .dm-link, .dm-empty-actions .btn { min-height: 44px; }
}

/* Phone: „Spustiť prevádzku“ spans the width, the tile values stay on one line where they fit */
@media (max-width: 480px) {
  .dm-mode-actions .btn { flex: 1 1 100%; }
  .dm-tile { padding: 12px 12px 10px; }
  .dm-tile-value { font-size: 20px; }
  .dm-stat-value { font-size: 16px; }
}

@media print {
  .dm-mode, .dm-op-banners, .dm-avatar, .dm-checkwrap, .dm-more, .dm-links, .dm-alert-actions { display: none !important; }
  .dm-task[hidden] { display: flex; }
}

/* v5 R25 „Kopírovať práce z minulého roka“ (alert kind copyYear): the last week (25. – 31. 1.) reads stronger; the button
   „Tento rok nie“ looks like the links beside it */
.dm-alert[data-kind="copyYear"][data-tone="warning-strong"] .dm-alert-title { font-weight: 700; }
/* round-14 fix P6: the last week is visibly stronger than the alerts around it (a red frame, red icon and title) */
.dm-alert[data-kind="copyYear"][data-tone="warning-strong"] { border: 2px solid var(--critical); }
.dm-alert[data-kind="copyYear"][data-tone="warning-strong"] .dm-alert-icon,
.dm-alert[data-kind="copyYear"][data-tone="warning-strong"] .dm-alert-title { color: var(--critical-text); }
/* round-14 fix P6: in January the notice sits right under the tiles (views/domov.js alertsTop) – on a wide screen its own row */
@media (min-width: 900px) {
  .dm-body:has(> .dm-alerts--top:not([hidden])) {
    grid-template-areas: "tiles tiles" "top top" "today alerts" "today month";
    grid-template-rows: auto auto auto 1fr;
  }
  .dm-alerts--top { grid-area: top; }
}
.dm-alert[data-kind="copyYear"] button.dm-alert-link { text-align: left; }
