/* Hlídač – vzhled aplikace.
   Barvy: chladný papír a smrková zelená; jantar = blíží se, červená = po termínu.
   Výrazným prvkem je sloupec s datem, všechno ostatní je střídmé. */

:root {
  --paper: #f3f6f5;
  --surface: #ffffff;
  --ink: #17262b;
  --muted: #56676d;
  --line: #d5dedd;
  --accent: #1e6b5a;
  --accent-ink: #ffffff;
  --accent-soft: #e2efeb;
  --soon: #8a5200;
  --soon-soft: #fbefd9;
  --overdue: #a8231c;
  --overdue-soft: #fbe5e3;

  --radius: 10px;
  --space: 1rem;
  --max: 40rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  color-scheme: light;
}

/* Tmavý vzhled: automaticky podle zařízení (pokud uživatel nezvolil světlý), nebo zvolený ručně.
   Stejné hodnoty jsou dvakrát, protože CSS neumí sdílet blok mezi @media a selektorem. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #132226;
    --surface: #1a2c31;
    --ink: #e6eeec;
    --muted: #9db0b0;
    --line: #2c4248;
    --accent: #5cc2a5;
    --accent-ink: #0d211b;
    --accent-soft: #1d3b36;
    --soon: #f2b655;
    --soon-soft: #3a2f1a;
    --overdue: #f28b82;
    --overdue-soft: #3d2124;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #132226;
  --surface: #1a2c31;
  --ink: #e6eeec;
  --muted: #9db0b0;
  --line: #2c4248;
  --accent: #5cc2a5;
  --accent-ink: #0d211b;
  --accent-soft: #1d3b36;
  --soon: #f2b655;
  --soon-soft: #3a2f1a;
  --overdue: #f28b82;
  --overdue-soft: #3d2124;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
}

a {
  color: var(--accent);
}

h1,
h2 {
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

h2 {
  font-size: 1.05rem;
  font-weight: 650;
}

h1:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--space);
  top: -3rem;
  background: var(--surface);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  z-index: 10;
}

.skip-link:focus {
  top: var(--space);
}

/* Hlavička */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  max-width: var(--max);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 0.75rem) var(--space) 0.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
}

.top nav {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.95rem;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-right: -0.5rem;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.icon-button:hover {
  color: var(--ink);
  background: var(--accent-soft);
}

/* Na úzkém telefonu se do hlavičky nevejde název i navigace, zůstane jen ikona. */
@media (max-width: 26rem) {
  .brand span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

.top nav a,
.link-button {
  color: var(--muted);
  text-decoration: none;
  padding: 0.25rem 0;
}

.top nav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.link-button {
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
}

/* Obsah */

.main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.5rem var(--space) 2.5rem;
}

/* Patička: zpětná vazba a ochrana údajů; dole místo pro potvrzovací hlášku */
.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem var(--space) calc(env(safe-area-inset-bottom) + 5rem);
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}

.foot a {
  color: var(--muted);
}

.loading {
  color: var(--muted);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  margin: 1rem 0 0.5rem;
}

.summary {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

.summary--soon {
  color: var(--soon);
  font-weight: 600;
}

.summary--overdue {
  color: var(--overdue);
  font-weight: 600;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

.notice {
  background: var(--soon-soft);
  color: var(--ink);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
}

.empty-note {
  color: var(--muted);
}

/* Seznam termínů */

.group {
  margin: 0 0 1.75rem;
}

.group h2,
.group summary {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
  font-weight: 650;
}

.group summary {
  cursor: pointer;
  color: var(--muted);
}

.count {
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.items {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.items > li + li {
  border-top: 1px solid var(--line);
}

.item {
  display: grid;
  grid-template-columns: 3.75rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem 0.75rem 0.75rem;
  color: inherit;
  text-decoration: none;
  border-left: 4px solid transparent;
}

.item:hover {
  background: var(--accent-soft);
}

.item--soon {
  border-left-color: var(--soon);
}

.item--overdue {
  border-left-color: var(--overdue);
  background: var(--overdue-soft);
}

.item--done {
  grid-template-columns: 1fr auto;
  padding-left: 1rem;
}

.item--done .item-title {
  color: var(--muted);
}

.item-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.item-day {
  font-size: 1.85rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.item--soon .item-day {
  color: var(--soon);
}

.item--overdue .item-day {
  color: var(--overdue);
}

.item-month {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.item-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.item-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.item-meta {
  font-size: 0.875rem;
  color: var(--muted);
}

.item-when {
  font-size: 0.875rem;
  color: var(--muted);
  text-align: right;
  max-width: 7.5rem;
}

.item--soon .item-when {
  color: var(--soon);
  font-weight: 600;
}

.item--overdue .item-when {
  color: var(--overdue);
  font-weight: 600;
}

/* Nemovitosti */

.property {
  padding: 0.75rem 1rem;
}

.property-view {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.row-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Stavy (prázdno, chyba, přihlášení) */

.state {
  margin: 2.5rem 0;
}

.state p {
  color: var(--muted);
  max-width: 34rem;
}

.login {
  margin: 3rem 0 0;
}

.login-title {
  font-size: 2.5rem;
  letter-spacing: -0.03em;
}

.login-lead {
  font-size: 1.15rem;
  color: var(--muted);
  margin: 0.5rem 0 2rem;
}

/* Formuláře */

.form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  border: 0;
  margin: 0;
  padding: 0;
}

.field label,
.field legend {
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0;
}

.field legend {
  margin-bottom: 0.35rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.1rem;
}

@media (min-width: 30rem) {
  .field-row {
    grid-template-columns: 1fr 1fr;
  }
}

input,
select,
textarea {
  width: 100%;
  min-height: 3rem;
  padding: 0.6rem 0.75rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

textarea {
  resize: vertical;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline-offset: 0;
  border-color: var(--accent);
}

.form-error {
  margin: 0;
  color: var(--overdue);
  font-weight: 600;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Tlačítka */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.5rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover {
  border-color: var(--accent);
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.button--primary {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.button--primary:hover {
  filter: brightness(1.08);
}

.button--danger {
  color: var(--overdue);
}

.button--danger:hover {
  border-color: var(--overdue);
}

.button--small {
  min-height: 2.25rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.9rem;
}

.button--wide {
  width: 100%;
}

/* Rychlá volba */

.chips {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}

.chips--wrap {
  flex-wrap: wrap;
}

/* Filtr oblastí: na telefonu jeden řádek, který jde posunout prstem. */
.chips--scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  margin: 0 calc(var(--space) * -1) 0.75rem;
  padding: 0.125rem var(--space);
  scrollbar-width: none;
}

.chips--scroll::-webkit-scrollbar {
  display: none;
}

.chips--scroll > li {
  flex-shrink: 0;
}

.form .chips {
  margin: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0.25rem 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chip--filter {
  gap: 0.4rem;
  white-space: nowrap;
}

.chip--filter[aria-pressed="true"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.chip--filter[aria-pressed="true"] .count {
  color: inherit;
  opacity: 0.8;
}

/* Filtry v přehledu */

.filters {
  margin: 0 0 1.5rem;
}

.filter-asset {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.filter-asset label {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
}

.filter-asset select {
  min-height: 2.5rem;
  max-width: 20rem;
}

.show-more {
  margin-top: 0.75rem;
}

/* Vyfocení dokladu na začátku nového termínu */

.capture {
  margin: 1rem 0 0;
}

.capture .hint {
  margin-top: 0.5rem;
}

.button--large {
  min-height: 3.5rem;
  font-size: 1.1rem;
}

.capture-status {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}

.capture-status p {
  margin: 0;
}

.capture-status p + p {
  margin-top: 0.35rem;
}

.capture-status--working p:first-child::before {
  content: "";
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  margin-right: 0.5rem;
  vertical-align: -0.1rem;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.capture-status--ok {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.capture-status--warn {
  border-color: var(--soon);
  background: var(--soon-soft);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .capture-status--working p:first-child::before {
    animation-duration: 3s;
  }
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.75rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

/* Pole vyplněné z dokladu: jemné zvýraznění, dokud ho uživatel neupraví */
.field.is-filled input,
.field.is-filled select,
.field.is-filled textarea {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.label {
  font-weight: 600;
  font-size: 0.95rem;
}

/* Doklady */

.docs {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form .docs {
  margin: 0.25rem 0 0.5rem;
}

.doc {
  display: grid;
  grid-template-columns: 3.5rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
}

.doc-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.doc-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.doc-icon {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}

.doc-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.doc-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

a.doc-name {
  color: var(--ink);
}

/* Panely pod formulářem */

.panel {
  margin-top: 2rem;
  padding: 1.25rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel h2 {
  margin-bottom: 0.75rem;
}

.panel p {
  margin: 0 0 1rem;
  color: var(--muted);
}

.panel .field {
  margin-bottom: 0.5rem;
}

.panel .hint {
  margin: 0 0 1rem;
}

.danger-zone {
  margin-top: 2rem;
}

/* Hledání v přehledu */

.search {
  margin: 0 0 0.75rem;
}

.search input {
  min-height: 2.75rem;
}

/* Co obvykle hlídat (prázdný přehled) */

.checklist {
  margin: 0 0 2rem;
}

.checklist h2 {
  margin-bottom: 0.25rem;
}

.checklist > .hint {
  margin: 0 0 1rem;
}

.checklist-group h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

.checklist-group .chips {
  margin-bottom: 1rem;
}

/* Nastavení */

.switch {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.switch input {
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  min-height: 0;
  margin: 0.1rem 0 0;
  accent-color: var(--accent);
}

.panel .switch + .hint {
  margin: 0.75rem 0 1rem;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented label {
  position: relative;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  min-height: 0;
}

.segmented span {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 1rem;
  font-weight: 600;
  color: var(--muted);
}

.segmented label + label span {
  border-left: 1px solid var(--line);
}

.segmented input:checked + span {
  color: var(--accent-ink);
  background: var(--accent);
}

.segmented input:focus-visible + span {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.panel .segmented + .hint {
  margin-top: 0.75rem;
}

.steps {
  margin: 0;
  padding-left: 1.25rem;
}

.steps li + li {
  margin-top: 0.5rem;
}

.danger-details {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.danger-details summary {
  cursor: pointer;
  color: var(--overdue);
  font-weight: 600;
}

.danger-details[open] summary {
  margin-bottom: 0.75rem;
}

.danger-details .field {
  margin-bottom: 0.75rem;
}

.panel .actions + .capture-status {
  margin-top: 1rem;
}

.panel .actions + .hint {
  margin-top: 0.75rem;
}

.capture-status .actions {
  margin-top: 0.75rem;
}

/* Delší text (ochrana osobních údajů) */

.prose {
  max-width: 36rem;
  margin: 1rem 0 0;
  line-height: 1.6;
}

.prose h2 {
  margin: 1.75rem 0 0.5rem;
}

.prose ul {
  padding-left: 1.25rem;
}

.prose li + li {
  margin-top: 0.4rem;
}

.prose-summary {
  margin: 1.25rem 0 0;
  padding: 0.75rem 1rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
}

.prose-summary p {
  margin: 0;
}

.prose-summary ul {
  margin: 0.5rem 0 0;
}

/* Potvrzení dole */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 1.25rem);
  transform: translate(-50%, 1rem);
  max-width: calc(100% - 2rem);
  padding: 0.75rem 1.1rem;
  color: var(--paper);
  background: var(--ink);
  border-radius: var(--radius);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}

@media (max-width: 22rem) {
  .item {
    grid-template-columns: 3rem 1fr;
  }

  .item-when {
    grid-column: 2;
    text-align: left;
    max-width: none;
  }
}
