:root {
  --bg: #edf0f3;
  --surface: #ffffff;
  --sunken: #f5f7f9;
  --ink: #1a2633;
  --muted: #5a6876;
  --line: #d3dae1;
  --primary: #1e4d8c;
  --primary-ink: #ffffff;
  --tag: #f2b705;
  --tag-ink: #1a2633;
  --ok: #2e7a4e;
  --ok-bg: #e3f2e9;
  --warn: #9a5f0c;
  --warn-bg: #fbf0dc;
  --bad: #a63330;
  --bad-bg: #f9e4e3;
  --radius: 6px;
  --font: "Archivo", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131a21;
    --surface: #1b242d;
    --sunken: #161e26;
    --ink: #e4e9ee;
    --muted: #97a4b1;
    --line: #2f3b47;
    --primary: #6f9fe0;
    --primary-ink: #0e1620;
    --tag: #f2b705;
    --tag-ink: #1a2633;
    --ok: #6cc596;
    --ok-bg: #18342a;
    --warn: #e2a54b;
    --warn-bg: #3a2d16;
    --bad: #ec8580;
    --bad-bg: #3d1f1f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  font-variation-settings: "wdth" 100;
}

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

h1, h2, h3 {
  font-weight: 800;
  font-variation-settings: "wdth" 88;
  line-height: 1.15;
  margin: 0 0 .5em;
}
h1 { font-size: 1.85rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.inline { display: inline; }

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

/* ---- Horní lišta ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: .6rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-variation-settings: "wdth" 80;
  font-size: 1.1rem;
}
.brand svg { width: 26px; height: 26px; }
.brand svg path { fill: var(--tag); }
.brand svg circle { fill: var(--ink); }
.nav { display: flex; gap: .15rem; flex-wrap: wrap; flex: 1; }
.nav a {
  padding: .4rem .7rem;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}
.nav a:hover { color: var(--ink); background: var(--sunken); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--sunken); box-shadow: inset 0 -2px 0 var(--tag); }
.nav-admin { font-variation-settings: "wdth" 85; }
.topbar-end { display: flex; align-items: center; gap: 1rem; }

.page { max-width: 1160px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; }

/* ---- Bloky ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.panel > h2:first-child { margin-top: 0; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-flush > h2 { padding: 1rem 1.25rem 0; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.25rem; align-items: start; }
.grid-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---- Čísla v přehledu ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.5rem; }
.stat { background: var(--surface); padding: 1rem 1.25rem; text-decoration: none; color: var(--ink); }
.stat strong { display: block; font-size: 2rem; font-weight: 800; font-variation-settings: "wdth" 75; line-height: 1; }
.stat span { color: var(--muted); font-size: .9rem; }
.stat.is-bad strong { color: var(--bad); }
.stat.is-warn strong { color: var(--warn); }
a.stat:hover { background: var(--sunken); }

/* ---- Cenovka ---- */
.tag {
  --h: 1.7em;
  display: inline-flex;
  align-items: center;
  height: var(--h);
  padding: 0 .75em 0 1.25em;
  background: var(--tag);
  color: var(--tag-ink);
  font-weight: 800;
  font-variation-settings: "wdth" 82;
  white-space: nowrap;
  clip-path: polygon(.7em 0, 100% 0, 100% 100%, .7em 100%, 0 50%);
  border-radius: 0 3px 3px 0;
  position: relative;
  font-variant-numeric: tabular-nums;
}
.tag::before {
  content: "";
  position: absolute;
  left: .55em;
  top: 50%;
  width: .32em;
  height: .32em;
  margin-top: -.16em;
  border-radius: 50%;
  background: var(--surface);
}
.tag-lg { font-size: 1.4rem; }

/* ---- Štítky stavů ---- */
.chip, .badge {
  display: inline-block;
  padding: .1em .55em;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.chip-active, .badge-active { background: var(--ok-bg); color: var(--ok); }
.chip-to_remove, .chip-error { background: var(--bad-bg); color: var(--bad); }
.chip-expired { background: var(--warn-bg); color: var(--warn); }
.chip-removed, .chip-queued, .badge-archived { background: var(--sunken); color: var(--muted); border-color: var(--line); }
.chip-none { color: var(--muted); border: 1px dashed var(--line); }
.badge-draft { background: var(--sunken); color: var(--ink); border-color: var(--line); }
.badge-sold { background: var(--tag); color: var(--tag-ink); }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chips .chip { font-size: .72rem; }

/* ---- Tabulky ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .65rem .9rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
th { font-size: .82rem; color: var(--muted); font-weight: 600; background: var(--sunken); }
tr:last-child td { border-bottom: 0; }
td.thumb { width: 64px; padding-right: 0; }
.thumb img, .thumb .noimg { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; display: block; background: var(--sunken); }
.row-title { font-weight: 600; color: var(--ink); text-decoration: none; }
.row-title:hover { color: var(--primary); }

/* ---- Formuláře ---- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.field-hint { font-weight: 400; color: var(--muted); font-size: .82rem; margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=tel], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .55rem .7rem;
}
textarea { min-height: 9rem; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.check { display: flex; align-items: center; gap: .45rem; font-weight: 400; }
.counter { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; float: right; font-weight: 400; }
.counter.over { color: var(--bad); font-weight: 600; }

.attr-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: .5rem; margin-bottom: .5rem; }

/* ---- Tlačítka ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font: inherit;
  font-weight: 600;
  padding: .5rem .95rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  line-height: 1.2;
}
.btn:hover { background: var(--sunken); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-danger { color: var(--bad); }
.btn-sm { padding: .3rem .65rem; font-size: .85rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; }

/* ---- Hlášky ---- */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border-left: 4px solid; }
.flash-ok { background: var(--ok-bg); border-color: var(--ok); }
.flash-error { background: var(--bad-bg); border-color: var(--bad); }
.flash-warn { background: var(--warn-bg); border-color: var(--warn); }
.warnings { margin: 0 0 1rem; padding: .8rem 1rem .8rem 2rem; background: var(--warn-bg); border-radius: var(--radius); }
.warnings li { margin: .15rem 0; }

.empty { padding: 2.5rem 1.25rem; text-align: center; color: var(--muted); }
.empty .btn { margin-top: .75rem; }

/* ---- Fotky ---- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; }
.photo { position: relative; border-radius: 4px; overflow: hidden; background: var(--sunken); aspect-ratio: 1; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .num { position: absolute; top: .3rem; left: .3rem; background: var(--ink); color: var(--surface); font-size: .72rem; font-weight: 600; padding: 0 .4em; border-radius: 3px; }
.photo .tools { position: absolute; inset: auto 0 0 0; display: flex; justify-content: center; gap: .25rem; padding: .3rem; background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.photo .tools button, .photo .tools a { background: rgba(255,255,255,.92); color: #1a2633; border: 0; border-radius: 3px; font-size: .75rem; padding: .15rem .45rem; cursor: pointer; text-decoration: none; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.25rem; text-align: center; color: var(--muted); margin-bottom: 1rem; }
.dropzone.drag { border-color: var(--primary); background: var(--sunken); }
.upload-log { font-size: .85rem; margin-top: .5rem; }

/* ---- Balíček pro kanál ---- */
.copy-field { margin-bottom: 1rem; }
.copy-field .head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .3rem; }
.copy-field .head label { margin: 0; }
.copy-value { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius); padding: .55rem .7rem; white-space: pre-wrap; word-break: break-word; }
.copy-value.multi { max-height: 18rem; overflow-y: auto; }
.btn-copy.done { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.help { border-left: 4px solid var(--tag); padding: .6rem .9rem; background: var(--sunken); border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 1rem; }

.channel-table td:first-child { font-weight: 600; }
.detail-photos { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .25rem; }
.detail-photos img { height: 140px; border-radius: 4px; display: block; }
.desc { white-space: pre-wrap; }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; }

/* ---- Přihlášení ---- */
.auth { max-width: 380px; margin: 8vh auto; }
.auth .brand { justify-content: center; margin-bottom: 1.25rem; font-size: 1.4rem; }
.auth .brand svg { width: 34px; height: 34px; }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.filters input[type=text] { width: auto; flex: 1; min-width: 180px; }
.filters select { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg a { padding: .45rem .8rem; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; background: var(--surface); }
.seg a + a { border-left: 1px solid var(--line); }
.seg a[aria-current="true"] { background: var(--ink); color: var(--surface); }

@media (max-width: 640px) {
  .topbar { gap: .6rem; }
  .nav { order: 3; width: 100%; }
  .page { padding-top: 1.25rem; }
  h1 { font-size: 1.5rem; }
  td.hide-sm, th.hide-sm { display: none; }
  .attr-row { grid-template-columns: 1fr 1fr auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
