:root {
  --bg: #f6f5f2; --panel: #fff; --ink: #1c2333; --muted: #6b7280; --line: #e5e3de;
  --navy: #14213d; --accent: #c8952e;
  --attention: #f2b544; --attention-bg: #fdf3dc;
  --trust: #5b9bd5; --trust-bg: #e4effa;
  --sale: #e58fa3; --sale-bg: #fbe6eb;
  --danger: #b42318; --ok: #157f3b;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
h1 { font-size: 1.4rem; margin: 0 0 .4rem; }
h2 { font-size: 1.15rem; margin: .4rem 0 .2rem; }
h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem 0 .3rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); background: #fdecea; padding: .5rem .75rem; border-radius: 8px; }
.ok { color: var(--ok); background: #e7f6ec; padding: .5rem .75rem; border-radius: 8px; }
.note { background: #fff7e0; border: 1px solid #f1d58a; padding: .5rem .75rem; border-radius: 8px; font-size: .9rem; }
.banner { background: #fff1c2; text-align: center; padding: .4rem 1rem; font-size: .9rem; }

.top { display: flex; align-items: center; justify-content: space-between; background: var(--navy); color: #fff; padding: .7rem 1.25rem; }
.brand { font-weight: 700; text-decoration: none; color: var(--accent); letter-spacing: .02em; }
.top nav { display: flex; gap: 1rem; align-items: center; }
.top nav a { text-decoration: none; opacity: .9; }
.top nav a:hover { opacity: 1; text-decoration: underline; }
main { max-width: 1400px; margin: 0 auto; padding: 1.25rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.panel.narrow { max-width: 760px; margin: 0 auto; }
.panel.login { max-width: 360px; margin: 3rem auto; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline { display: inline; margin: 0; }

label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; font-weight: 600; }
input, select, textarea { font: inherit; font-weight: 400; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

.btn { display: inline-block; font: inherit; font-size: .9rem; padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #c9c6bf; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: #1f3260; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .6; cursor: wait; }
.link { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; opacity: .9; padding: 0; }
.link:hover { text-decoration: underline; }

.plan-list { list-style: none; padding: 0; margin: 0; }
.plan-list li a { display: flex; flex-direction: column; padding: .7rem .2rem; border-bottom: 1px solid var(--line); text-decoration: none; }
.plan-list li a:hover strong { text-decoration: underline; }

.plan-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.plan-head form { margin: 0; }
.legend { display: flex; gap: .4rem 1rem; align-items: center; font-size: .85rem; margin-bottom: .75rem; flex-wrap: wrap; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: -.6rem; }
.dot.phase-pozornost { background: var(--attention); }
.dot.phase-duvera { background: var(--trust); }
.dot.phase-prodej { background: var(--sale); }

.plan-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); gap: 1.25rem; align-items: start; }
.calendar { display: flex; flex-direction: column; gap: .9rem; }
.week { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: .6rem; align-items: stretch; }
.week-label { font-weight: 700; font-size: .9rem; padding-top: .5rem; }
.week-label.sales { color: #c2416a; }
.week-days { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .5rem; }

.card { text-align: left; display: flex; flex-direction: column; gap: .15rem; padding: .55rem .6rem; min-height: 110px; border-radius: 9px; border: 1px solid transparent; border-left: 5px solid; cursor: pointer; font: inherit; color: var(--ink); transition: transform .08s ease, box-shadow .08s ease; }
.card:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(20, 33, 61, .12); }
.card.selected { outline: 2px solid var(--navy); outline-offset: 1px; }
.card.phase-pozornost { background: var(--attention-bg); border-left-color: var(--attention); }
.card.phase-duvera { background: var(--trust-bg); border-left-color: var(--trust); }
.card.phase-prodej { background: var(--sale-bg); border-left-color: var(--sale); }
.card.st-publikovano { opacity: .55; }
.card.card-missing { background: #fff; border: 2px dashed #b9b5ac; }
.card.card-missing .card-title { color: var(--danger); }
.card.card-missing .card-meta { color: var(--danger); font-weight: 600; }
.card-top { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); }
.card-status { font-weight: 600; color: var(--ok); }
.card-type { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; color: #4b5563; }
.card-title { font-size: .85rem; font-weight: 600; line-height: 1.3; }
.card-meta { font-size: .72rem; color: var(--muted); margin-top: auto; }

.detail { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
.back-to-cal { display: none; margin-bottom: .6rem; color: var(--muted); }
.pills { display: flex; gap: .35rem; flex-wrap: wrap; }
.pill { font-size: .72rem; padding: .15rem .5rem; border-radius: 999px; background: #f0eee9; font-weight: 600; }
.pill.phase-pozornost { background: var(--attention); }
.pill.phase-duvera { background: var(--trust); color: #fff; }
.pill.phase-prodej { background: var(--sale); }
.hook { font-size: 1.05rem; font-weight: 600; margin: 0; white-space: pre-wrap; }
.body { white-space: pre-wrap; margin: 0; }
.detail .row { margin-top: 1rem; }
.detail .row.undo { margin-top: .6rem; }
.regen p.small { margin: .4rem 0 0; }
.regen { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.regen .row { margin-top: .35rem; flex-wrap: nowrap; }
.regen input { flex: 1; }
.edit { display: flex; flex-direction: column; gap: .7rem; }

.generating { display: flex; gap: 1rem; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.generating p { margin: .2rem 0 0; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; flex: none; }
.spinner.small { display: inline-block; width: 14px; height: 14px; border-width: 2px; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }

@media (max-width: 1100px) {
  .plan-layout { grid-template-columns: 1fr; }
  .detail { position: static; max-height: none; }
  .back-to-cal { display: inline-block; }
}
@media (max-width: 760px) {
  main { padding: .75rem; }
  .cols, .grid2 { grid-template-columns: 1fr; }
  .week { grid-template-columns: 1fr; }
  .week-days { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .week-days .card:last-child:nth-child(odd) { grid-column: span 2; min-height: 0; }
  .card { min-height: 96px; }
}
