/* Panel hodowcy – duże litery, duże przyciski, jedna rzecz na ekranie. */
:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --fg: #262825;
  --muted: #5d625c;
  --line: #d9d3c8;
  --brand: #6e4f24;
  --brand-hover: #573e1b;
  --ok: #2f6b3a;
  --ok-bg: #e5f2e6;
  --bad: #a3271f;
  --bad-bg: #fbe8e6;
  --info-bg: #fdf3df;
  --r: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 19px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid #e0a43c; outline-offset: 2px; }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem clamp(1rem, 3vw, 2rem); background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--fg); font-weight: 700; font-size: 1.1rem; line-height: 1.15; }
.brand img { width: 2.4rem; height: 2.4rem; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; }
.top-links { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.tbtn { white-space: nowrap; display: inline-flex; align-items: center; min-height: 44px; padding: .4rem .95rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--fg); text-decoration: none; font-size: .9rem; font-weight: 600; cursor: pointer; }
.tbtn:hover { border-color: var(--brand); color: var(--brand); }

.app { max-width: 56rem; margin: 0 auto; padding: 1.4rem clamp(1rem, 3vw, 2rem) 8rem; }
.loading { color: var(--muted); font-size: 1.2rem; padding: 3rem 0; text-align: center; }
h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); line-height: 1.2; margin: .4rem 0 .4rem; }
h2 { font-size: 1.3rem; margin: 2rem 0 .8rem; }
.lead { color: var(--muted); margin: 0 0 1.5rem; }
.back { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: 0 .2rem; color: var(--brand); font-weight: 600; text-decoration: none; }
.back:hover { text-decoration: underline; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 56px; padding: .7rem 1.5rem; border: 2px solid var(--brand); border-radius: var(--r); background: var(--brand); color: #fff; font-weight: 700; font-size: 1.05rem; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.ghost { background: var(--card); color: var(--brand); }
.btn.ghost:hover { background: #f3ece1; }
.btn.danger { background: var(--card); color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { min-height: 44px; padding: .45rem 1rem; font-size: .95rem; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .55; cursor: wait; }

/* Start */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.tile { display: flex; flex-direction: column; gap: .3rem; padding: 1.3rem 1.3rem 1.2rem; min-height: 9rem; border: 2px solid var(--line); border-radius: var(--r); background: var(--card); color: var(--fg); text-decoration: none; }
.tile:hover { border-color: var(--brand); }
.tile .ic { font-size: 2rem; line-height: 1; }
.tile b { font-size: 1.2rem; }
.tile span { color: var(--muted); font-size: .95rem; }
.tile.main { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 1.1rem; min-height: 0; background: var(--brand); border-color: var(--brand); color: #fff; }
.tile.main span { color: #f1e6d4; }
.tile.main b { display: block; font-size: 1.3rem; }
.tile.main:hover { background: var(--brand-hover); }

/* Listy */
.bar { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; }
.list { display: grid; gap: .7rem; }
.row { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) auto; gap: 1rem; align-items: center; padding: .7rem 1rem .7rem .7rem; border: 2px solid var(--line); border-radius: var(--r); background: var(--card); color: var(--fg); text-decoration: none; }
.row:hover { border-color: var(--brand); }
.row .th { width: 4.5rem; height: 4.5rem; border-radius: 8px; object-fit: cover; background: #ece6dc; }
.row .noimg { width: 4.5rem; height: 4.5rem; border-radius: 8px; background: #ece6dc; display: grid; place-items: center; font-size: 1.6rem; }
.row b { display: block; font-size: 1.08rem; }
.row small { display: block; color: var(--muted); font-size: .92rem; }
.row .go { color: var(--brand); font-weight: 700; white-space: nowrap; }
.group-title { margin: 1.8rem 0 .7rem; font-size: 1.05rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.empty { padding: 1.4rem; border: 2px dashed var(--line); border-radius: var(--r); color: var(--muted); text-align: center; }

/* Formularz */
.form { display: grid; gap: 1.4rem; }
.f { display: grid; gap: .4rem; }
.f > label, .f > .lab { font-weight: 700; }
.f .hint { color: var(--muted); font-size: .92rem; margin-top: -.2rem; }
.req { color: var(--bad); }
input[type=text], input[type=date], input[type=number], input[type=email], input[type=tel], input[type=url], input[type=password], select, textarea {
  width: 100%; min-height: 54px; padding: .7rem .9rem; border: 2px solid #bdb5a7; border-radius: 10px; background: #fff;
}
textarea { min-height: 8rem; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px #e9d9bd; }
.f.err input, .f.err select, .f.err textarea { border-color: var(--bad); }
.f .msg { color: var(--bad); font-weight: 600; font-size: .95rem; }
.check { display: flex; align-items: center; gap: .8rem; min-height: 54px; padding: .5rem .9rem; border: 2px solid #bdb5a7; border-radius: 10px; background: #fff; cursor: pointer; font-weight: 600; }
.check input { width: 1.6rem; height: 1.6rem; accent-color: var(--brand); flex: none; }

.more { border: 2px solid var(--line); border-radius: var(--r); background: var(--card); }
.more > summary { cursor: pointer; list-style: none; padding: 1rem 1.2rem; font-weight: 700; color: var(--brand); min-height: 56px; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: "▸ "; }
.more[open] > summary::before { content: "▾ "; }
.more > .form { padding: 0 1.2rem 1.3rem; }

/* Zdjęcia */
.photo-one { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr); gap: 1rem; align-items: start; }
.photo-one .pv { aspect-ratio: 4 / 5; border-radius: 10px; overflow: hidden; background: #ece6dc; display: grid; place-items: center; color: var(--muted); text-align: center; padding: .5rem; font-size: .95rem; }
.photo-one .pv img { width: 100%; height: 100%; object-fit: cover; }
.photo-one .acts { display: grid; gap: .6rem; align-content: start; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .8rem; }
.thumb { border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #ece6dc; }
.thumb .tacts { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.thumb .tacts button { min-height: 46px; border: 0; border-top: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 1.05rem; }
.thumb .tacts button + button { border-left: 1px solid var(--line); }
.thumb .tacts button:hover { background: #f3ece1; }
.thumb .tacts .del { color: var(--bad); font-weight: 700; }
.thumb .tacts button[disabled] { color: #c9c2b6; cursor: default; background: var(--card); }
.thumb .num { display: block; padding: .2rem .5rem; font-size: .8rem; color: var(--muted); }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

/* Lista tekstów i wierszy */
.lines { display: grid; gap: .6rem; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; }
.xbtn { min-width: 54px; min-height: 54px; border: 2px solid var(--line); border-radius: 10px; background: var(--card); color: var(--bad); font-weight: 700; cursor: pointer; font-size: 1.1rem; }
.xbtn:hover { border-color: var(--bad); background: var(--bad-bg); }
.rows { display: grid; gap: .9rem; }
.subcard { border: 2px solid var(--line); border-radius: var(--r); background: #fbfaf7; padding: 1rem; display: grid; gap: 1rem; }
.subcard-h { display: flex; justify-content: space-between; align-items: center; gap: .6rem; font-weight: 700; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }

/* Pasek zapisu */
.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--card); border-top: 2px solid var(--line); padding: .8rem clamp(1rem, 3vw, 2rem) calc(.8rem + env(safe-area-inset-bottom)); box-shadow: 0 -6px 18px rgba(0,0,0,.06); }
.savebar .in { max-width: 56rem; margin: 0 auto; display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.savebar .btn { flex: 1 1 12rem; }
.savebar .state { flex: 1 1 100%; color: var(--muted); font-size: .92rem; text-align: center; order: 3; }
.savebar.dirty .state { color: var(--brand); font-weight: 700; }

/* Komunikaty */
.notice { position: sticky; top: 4.1rem; z-index: 19; max-width: 56rem; margin: .8rem auto 0; padding: 1rem 1.2rem; border-radius: var(--r); font-weight: 600; display: flex; gap: .8rem; align-items: center; justify-content: space-between; flex-wrap: wrap; width: calc(100% - 2rem); }
.notice.ok { background: var(--ok-bg); color: var(--ok); border: 2px solid #a9d1ad; }
.notice.bad { background: var(--bad-bg); color: var(--bad); border: 2px solid #eab3ad; }
.notice.info { background: var(--info-bg); color: #6b4a12; border: 2px solid #ecd29c; }
.notice .x { border: 0; background: none; font-size: 1.4rem; cursor: pointer; color: inherit; min-width: 44px; min-height: 44px; }

.modal { position: fixed; inset: 0; z-index: 50; background: rgba(20, 18, 14, .55); display: grid; place-items: center; padding: 1rem; }
.modal-box { background: var(--card); border-radius: 16px; padding: 1.6rem; max-width: 30rem; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-box p { margin: 0 0 1.4rem; font-size: 1.15rem; font-weight: 600; }
.modal-btns { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }

/* Logowanie */
.login { max-width: 26rem; margin: 3rem auto; background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 2rem 1.6rem; display: grid; gap: 1.2rem; }
.login h1 { margin: 0; }
.login .msg { color: var(--bad); font-weight: 600; }
.box { background: var(--card); border: 2px solid var(--line); border-radius: var(--r); padding: 1.3rem; }

.danger-zone { margin-top: 3rem; padding-top: 1.5rem; border-top: 2px dashed var(--line); }

@media (max-width: 640px) {
  body { font-size: 18px; }
  .photo-one { grid-template-columns: 1fr; }
  .photo-one .pv { max-width: 16rem; }
  .grid2 { grid-template-columns: 1fr; }
  .row { grid-template-columns: 3.6rem minmax(0, 1fr); }
  .row .th, .row .noimg { width: 3.6rem; height: 3.6rem; }
  .row .go { display: none; }
  .brand small { display: none; }
  .brand { font-size: 1rem; }
  .brand img { width: 2rem; height: 2rem; }
  .top { padding: .5rem 1rem; }
  .top-links { flex-wrap: nowrap; gap: .4rem; }
  .tbtn { padding: .35rem .75rem; }
  .tbtn .long { display: none; }
  .savebar .in { flex-wrap: nowrap; gap: .6rem; }
  .savebar .btn { flex: 1 1 0; min-height: 52px; padding: .5rem .6rem; font-size: 1rem; }
  .savebar .btn .long { display: none; }
  .savebar .state { display: none; }
  .app { padding-bottom: 6.5rem; }
  .notice { top: 3.8rem; }
}

@media (min-width: 641px) { .short { display: none; } }

/* Kadrowanie */
.fmodal .fbox { max-width: 46rem; max-height: 94vh; overflow: auto; }
.fpick { position: relative; display: inline-block; cursor: crosshair; max-width: 100%; margin-bottom: 1rem; }
.fpick img { max-width: 100%; max-height: 42vh; width: auto; border-radius: 8px; }
.fdot { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 4px solid #fff; border-radius: 50%; box-shadow: 0 0 0 3px var(--brand), 0 2px 10px rgba(0,0,0,.5); pointer-events: none; }
.fprev { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; margin-bottom: 1.2rem; font-size: .9rem; color: var(--muted); }
.fprev > div { display: grid; gap: .3rem; }
.fp { border-radius: 8px; overflow: hidden; background: #ece6dc; margin-top: .3rem; }
.fp.tall { aspect-ratio: 4 / 5; width: 7rem; } .fp.wide { aspect-ratio: 16 / 9; width: 15rem; max-width: 100%; }
.fp img { width: 100%; height: 100%; object-fit: cover; }
.thumb .kadr { display: block; width: 100%; min-height: 44px; border: 0; border-top: 1px solid var(--line); background: var(--card); color: var(--brand); font-weight: 700; cursor: pointer; }
.thumb .kadr:hover { background: #f3ece1; }
/* Kolejność, historia */
.row.ord, .row.hist { grid-template-columns: 4.5rem minmax(0, 1fr) auto; }
.row.hist { grid-template-columns: 3rem minmax(0, 1fr); padding: .5rem .9rem; }
.row.hist .noimg { width: 3rem; height: 3rem; font-size: 1.2rem; }
.ordbtns { display: flex; gap: .4rem; }
.ordbtns .xbtn { color: var(--brand); }
.ordbtns .xbtn[disabled] { color: #c9c2b6; cursor: default; background: var(--card); border-color: var(--line); }
.box.undo { border-color: #e2c48d; background: var(--info-bg); }
.tiles + .group-title { margin-top: 2.4rem; }
@media (max-width: 640px) { .row.ord { grid-template-columns: 3.6rem minmax(0, 1fr) auto; } .fp.wide { width: 12rem; } }

.box.warn { border-color: #e7a69e; background: var(--bad-bg); color: var(--bad); margin-bottom: 1.4rem; }

.tile.main.alt { background: #fff; color: var(--brand); border: 2px solid var(--brand); }
.tile.main.alt span { color: var(--muted); }
.tile.main.alt:hover { background: #f3ece1; }
/* tryb wbudowany (okno na stronie) */
.embed .top, .embed .back { display: none; }
.embed .notice { top: .5rem; }
.embed .app { padding-top: .6rem; }
