/* Photo Autopilot — панель. Мобільна версія першою; світла й темна теми. */
:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --ink: #1b1c1e;
  --muted: #6a6c72;
  --line: #e2dfd8;
  --accent: #2c5f55;
  --accent-ink: #ffffff;
  --accent-soft: #e3efec;
  --warn: #9a5b00;
  --warn-soft: #fbf0d9;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --ok: #1d7a4a;
  --ok-soft: #e0f1e8;
  --radius: 12px;
  --gutter: 16px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 14px rgb(0 0 0 / .04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121314; --surface: #1c1d1f; --ink: #ececec; --muted: #9a9ca3; --line: #2e3033;
    --accent: #6fb7a6; --accent-ink: #0d1a17; --accent-soft: #1d2d29;
    --warn: #e8b15a; --warn-soft: #32280f; --bad: #f2908a; --bad-soft: #351a18;
    --ok: #6fcf9b; --ok-soft: #14291e;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
code { background: var(--accent-soft); padding: .05em .35em; border-radius: 5px; font-size: .9em; }
pre { white-space: pre-wrap; word-break: break-word; font: inherit; margin: .5rem 0 0; }
img, video { max-width: 100%; display: block; }
.small { font-size: .85rem; }
.muted { color: var(--muted); }
.warn-text { color: var(--warn); }
.bad-text, .error { color: var(--bad); }
.ok-text { color: var(--ok); }
.top-gap { margin-top: .75rem; }

/* шапка */
.top { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.top-row { display: flex; align-items: center; gap: 12px; padding: 10px var(--gutter) 4px; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); letter-spacing: .01em; }
.pc { margin-left: auto; font-size: .78rem; padding: 2px 9px; border-radius: 99px; background: var(--ok-soft); color: var(--ok); }
.pc-off { background: var(--bad-soft); color: var(--bad); }
.logout { margin: 0; }
.tabs, .subtabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 0 var(--gutter); -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar, .subtabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 12px; text-decoration: none; color: var(--muted); white-space: nowrap; border-bottom: 3px solid transparent; font-weight: 500; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.subtabs { padding: 0; margin: 0 0 14px; }
.subtabs a { padding: 7px 12px; border-radius: 99px; text-decoration: none; color: var(--muted); background: var(--surface); border: 1px solid var(--line); white-space: nowrap; font-size: .9rem; }
.subtabs a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

main { max-width: 1100px; margin: 0 auto; padding: 16px var(--gutter) 64px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.crumbs { margin: 0 0 8px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* повідомлення */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.bad { background: var(--bad-soft); color: var(--bad); }
.notice { background: var(--warn-soft); color: var(--warn); padding: 8px 12px; border-radius: 10px; }
.alerts { background: var(--warn-soft); border-radius: var(--radius); padding: 8px 14px; margin-bottom: 12px; }
.alerts summary { cursor: pointer; color: var(--warn); font-weight: 600; }
.alerts ul { margin: 8px 0; padding-left: 18px; }
.alerts li.error { color: var(--bad); }

/* картки */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 6px; }
.card.is-off { opacity: .6; }
.grid.cards { display: grid; grid-template-columns: 1fr; gap: 12px; }
.grid.cards > .card { margin: 0; }
.cols { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 760px) {
  .grid.cards { grid-template-columns: repeat(2, 1fr); }
  .cols { grid-template-columns: 1.2fr 1fr; }
}
@media (min-width: 1000px) { .grid.cards { grid-template-columns: repeat(3, 1fr); } }

.badge { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.kind { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.badge.today { background: var(--accent); color: var(--accent-ink); }
.badge.bad, .badge.st-failed, .badge.ws-error { background: var(--bad-soft); color: var(--bad); }
.badge.warn, .badge.st-open, .badge.ws-new { background: var(--warn-soft); color: var(--warn); }
.badge.st-published, .badge.ws-ready { background: var(--ok-soft); color: var(--ok); }
.chip { display: inline-block; font-size: .8rem; padding: 3px 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); }
.chip.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.stats { margin: 0; display: flex; gap: 6px; flex-wrap: wrap; }

/* календар */
.day { margin-bottom: 18px; }
.day h2 { position: sticky; top: 92px; z-index: 5; background: var(--bg); padding: 6px 0; margin-bottom: 6px; font-size: 1rem; }
.slot-head .time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; }
.slot.is-failed { border-color: var(--bad); }
.slot.is-open { border-style: dashed; background: transparent; box-shadow: none; }
.media { margin: 8px 0; border-radius: 10px; overflow: hidden; background: var(--bg); }
.media img, .media video { width: 100%; max-height: 70vh; object-fit: contain; margin: 0 auto; }
.media-photo img { max-width: 460px; }
.carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 6px; -webkit-overflow-scrolling: touch; }
.carousel figure { flex: 0 0 82%; max-width: 440px; margin: 0; scroll-snap-align: center; position: relative; }
.carousel figcaption { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; color: var(--muted); padding: 4px 6px; }
.carousel figcaption form { margin: 0; }
.square-wrap { padding: 8px; }
.square { width: min(280px, 100%); aspect-ratio: 1 / 1; overflow: hidden; border-radius: 8px; display: inline-block; margin-right: 6px; }
.square img { width: 100%; height: 100%; object-fit: cover; }
.media-reel video { max-width: 320px; max-height: 70vh; background: #000; }
.caption { white-space: pre-wrap; word-break: break-word; margin: .5rem 0 .25rem; }
.tags { color: var(--accent); margin: .1rem 0; word-break: break-word; font-size: .9rem; }
.meta { margin: .25rem 0; }
.story { margin: .25rem 0; }

/* кнопки й форми */
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-top: 10px; }
.actions form, form.inline { margin: 0; display: inline; }
.btn, button.btn, summary.btn { display: inline-block; cursor: pointer; font: inherit; font-size: .92rem; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; min-height: 40px; list-style: none; }
summary.btn::-webkit-details-marker { display: none; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.bad { color: var(--bad); border-color: var(--bad); }
.btn[disabled] { opacity: .5; cursor: default; }
.small-btn { font-size: .8rem; min-height: 32px; padding: 4px 10px; }
.mini { font: inherit; font-size: .75rem; padding: 3px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.mini.on { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 4px 0; text-decoration: underline; }
.pop { display: inline-block; }
.pop[open] { display: block; width: 100%; }
.pop > form { margin-top: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.reasons { display: flex; flex-wrap: wrap; gap: 6px; }
.reasons .btn { min-height: 36px; padding: 6px 10px; font-size: .85rem; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.two { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 600px) { .two { grid-template-columns: 1fr 1fr; } }
label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: .95rem; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 40px; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
input.need { border-color: var(--warn); }
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; margin: 0 0 14px; }
.filters label { min-width: 150px; flex: 1 1 150px; max-width: 260px; }
.filters label.check { flex: 0 0 auto; min-width: 0; }
.row-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.row-form input { flex: 1 1 160px; width: auto; }

/* весілля */
.facts { display: flex; gap: 18px; margin: 8px 0; }
.facts div { display: flex; flex-direction: column; }
.facts dt { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 0; font-weight: 700; font-size: 1.1rem; }
.progress { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 6px; }
.progress span { display: block; height: 100%; background: var(--accent); }
.title { font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--ink); }
.access, .list { list-style: none; margin: 0; padding: 0; }
.access li, .list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.access li:last-child, .list li:last-child { border-bottom: 0; }
.list.logs li { display: block; }
.list li.error, .list li.warn { color: inherit; }
.list li.error time { color: var(--bad); }
.list li.warn time { color: var(--warn); }
.list.locs li { display: block; }
.sheets { display: flex; gap: 8px; overflow-x: auto; }
.sheets img { height: 180px; width: auto; border-radius: 8px; }
.photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .photos { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .photos { grid-template-columns: repeat(4, 1fr); } }
.photo { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.photo.is-excluded { opacity: .5; }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photo .noimg { aspect-ratio: 4 / 3; display: grid; place-items: center; color: var(--muted); background: var(--bg); font-size: .8rem; }
.photo figcaption { padding: 6px 8px 8px; }
.photo .row { display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.photo .ctl { margin-top: 6px; gap: 4px; flex-wrap: wrap; justify-content: flex-start; }
.photo .ctl form { margin: 0; }
.photo .ctl select { min-height: 30px; padding: 2px 6px; font-size: 13px; width: auto; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 14px; }

/* матриця */
.matrix-wrap { overflow: auto; max-height: 75vh; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.matrix { border-collapse: separate; border-spacing: 0; font-size: .85rem; }
.matrix th, .matrix td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: center; background: var(--surface); }
.matrix thead th { position: sticky; top: 0; z-index: 2; height: 130px; vertical-align: bottom; }
.matrix th.acc span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.matrix th.acc.mw { color: var(--accent); }
.matrix .sticky-col { position: sticky; left: 0; z-index: 1; text-align: left; min-width: 170px; max-width: 220px; background: var(--surface); }
.matrix thead .sticky-col { z-index: 3; }
.matrix .sticky-col span { display: block; }
.matrix td.manual { background: var(--accent-soft); }
.matrix td.saving { opacity: .5; }

.report pre { background: var(--bg); padding: 12px; border-radius: 10px; }
.report summary { cursor: pointer; }
.token { border-top: 1px solid var(--line); padding: 8px 0; }
.token summary { cursor: pointer; display: flex; gap: 8px; align-items: center; }

/* вхід */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login { width: min(380px, 100% - 32px); background: var(--surface); padding: 24px; border-radius: 16px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 99px; font-size: .9rem; z-index: 50; }
.toast.bad { background: var(--bad); color: #fff; }
