/* ------------------------------------------------------------------
   Statistika opakovaných nákupů – vzhled
   Světlý i tmavý režim, jedna akcentní barva, hodně vzduchu.
   ------------------------------------------------------------------ */

:root {
  color-scheme: light;

  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04);

  --s1: #2a78d6;          /* hlavní datová barva */
  --s1-soft: #86b6ef;     /* světlejší krok téhož odstínu */
  --s1-wash: rgba(42, 120, 214, 0.1);
  --s2: #eb6834;          /* druhá série */
  --good: #0ca30c;
  --critical: #d03b3b;

  --radius: 14px;
  --radius-sm: 9px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;

    --plane: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232322;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: none;

    --s1: #3987e5;
    --s1-soft: #184f95;
    --s1-wash: rgba(57, 135, 229, 0.12);
    --s2: #d95926;
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;

  --plane: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: none;

  --s1: #3987e5;
  --s1-soft: #184f95;
  --s1-wash: rgba(57, 135, 229, 0.12);
  --s2: #d95926;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* --- hlavička --------------------------------------------------- */

.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
}

.masthead h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.masthead p {
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 14px;
  max-width: 60ch;
}

.theme-toggle {
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.theme-toggle:hover { color: var(--ink); }

/* --- karty ------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.intake { padding: 24px; }

.intake-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.intake label {
  display: block;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 8px;
}

input[type='url'],
input[type='date'],
select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

input[type='url'] { flex: 1 1 380px; min-width: 0; }

input:focus-visible,
select:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--s1);
  outline-offset: 2px;
}

.btn {
  font: inherit;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  background: var(--s1);
  color: #fff;
  cursor: pointer;
}

.btn:hover { filter: brightness(0.94); }
.btn:disabled { opacity: 0.5; cursor: default; filter: none; }

.btn-quiet {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--border);
}

.btn-quiet:hover { color: var(--ink); filter: none; background: var(--surface-2); }

.intake-alt {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--s1);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hint {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* --- průběh ----------------------------------------------------- */

.progress { margin-top: 20px; }

.progress[hidden] { display: none; }

.progress-track {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--s1);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.progress-fill.indeterminate {
  width: 35%;
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

@media (prefers-reduced-motion: reduce) {
  .progress-fill.indeterminate { animation: none; width: 100%; opacity: 0.4; }
}

.progress-text {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.alert {
  margin-top: 20px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
}

.alert[hidden] { display: none; }
.alert strong { color: var(--critical); }

/* --- filtry ----------------------------------------------------- */

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 16px 20px;
  margin: 32px 0 20px;
}

.filter { display: flex; flex-direction: column; gap: 6px; }

.filter > span {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.filter-row { display: flex; gap: 8px; align-items: center; }

.filters .spacer { flex: 1; }

details.statuses { position: relative; }

details.statuses > summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface);
  font-size: 15px;
  white-space: nowrap;
}

details.statuses > summary::-webkit-details-marker { display: none; }

.status-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  min-width: 320px;
  max-height: 340px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(11, 11, 11, 0.12);
  padding: 10px;
}

.status-panel label {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 7px 8px;
  border-radius: 7px;
  font-size: 14px;
  cursor: pointer;
}

.status-panel label:hover { background: var(--surface-2); }
.status-panel .count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

.status-panel .panel-actions {
  display: flex;
  gap: 14px;
  padding: 8px 8px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

/* --- hero + dlaždice -------------------------------------------- */

.hero {
  padding: 28px 32px;
  display: flex;
  gap: 36px;
  align-items: center;
  flex-wrap: wrap;
}

.hero-figure {
  font-size: 60px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.hero-body { flex: 1 1 320px; }

.hero-body h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
}

.hero-body p {
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin: 14px 0 0;
}

.tile { padding: 18px 20px; }

.tile .label {
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.tile .value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tile .note {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
}

/* --- grafy ------------------------------------------------------ */

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

@media (max-width: 720px) {
  .charts { grid-template-columns: 1fr; }
}

.chart-card { padding: 20px 22px 18px; position: relative; }
.chart-card.wide { grid-column: 1 / -1; }

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.chart-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.chart-head p {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 52ch;
}

.toggle-table {
  flex: none;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
}

.toggle-table:hover { background: var(--surface-2); color: var(--ink); }
.toggle-table[aria-pressed='true'] { background: var(--surface-2); color: var(--ink); }

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 10px 0 2px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.legend span { display: inline-flex; align-items: center; gap: 7px; }

.legend i {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
}

.plot { margin-top: 8px; }
.plot svg { display: block; width: 100%; height: auto; }

.chart-note {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.empty {
  padding: 28px 4px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

/* tabulkové zobrazení */

.table-view { margin-top: 10px; overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

th, td {
  text-align: right;
  padding: 7px 10px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}

th:first-child, td:first-child { text-align: left; }

thead th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12.5px;
}

tbody tr:last-child td { border-bottom: 0; }

/* tooltip */

.tip {
  position: absolute;
  z-index: 30;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(11, 11, 11, 0.14);
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.1s ease;
}

.tip.on { opacity: 1; }
.tip .tip-title { color: var(--muted); margin-bottom: 3px; }
.tip .tip-row { display: flex; align-items: center; gap: 7px; }
.tip .tip-row i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.tip .tip-row b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* --- patička ---------------------------------------------------- */

.meta-note {
  margin-top: 28px;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  gap: 8px 18px;
  flex-wrap: wrap;
}

section[hidden] { display: none; }
