[hidden] { display: none !important; }
:root {
  --bg: #f6f4ef; --card: #fff; --ink: #1f2328; --muted: #6b6f76; --line: #e4e0d6;
  --gold: #a88438; --gold-d: #8a6b28; --ok: #1f7a3a; --err: #b3261e; --warn-bg: #fef3c7;
  --r: 10px; --nav: 220px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--gold-d); }
h1 { font-size: 26px; margin: 4px 0 18px; font-weight: 650; }
h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* górny pasek i boczne menu */
.top { position: sticky; top: 0; z-index: 20; height: 58px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 650; }
.brand img { height: 34px; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.top-actions form { margin: 0; }
.navtoggle { display: none; border: 0; background: none; font-size: 22px; cursor: pointer; padding: 6px; }
.side { position: fixed; top: 58px; bottom: 0; left: 0; width: var(--nav); background: #fff; border-right: 1px solid var(--line);
  padding: 14px 10px; overflow-y: auto; z-index: 15; }
.side a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.side a:hover { background: var(--bg); }
.side a.on { background: #f3ead6; color: var(--gold-d); font-weight: 600; }
.side .sec { margin: 16px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.side .who { margin: 24px 12px 0; font-size: 13px; color: var(--muted); }
.side .who a { display: inline; padding: 0; color: var(--gold-d); }
main { padding: 24px 28px 80px; max-width: 1200px; }
main.with-nav { margin-left: var(--nav); }

/* przyciski */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #cfc7b4; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.primary:hover { background: var(--gold-d); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: wait; }
.badge { background: #fff; color: var(--gold-d); border-radius: 999px; padding: 0 7px; font-size: 12px; min-width: 20px; text-align: center; }
button.link { background: none; border: 0; color: var(--gold-d); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
button.link.danger { color: var(--err); }

.flash { padding: 12px 16px; border-radius: var(--r); margin-bottom: 16px; background: #e8f5ec; color: var(--ok); border: 1px solid #bfe3cb; }
.flash.err { background: #fdecea; color: var(--err); border-color: #f5c6c2; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 18px; }
.card summary { cursor: pointer; font-weight: 600; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl.small td { font-size: 13px; }
.tbl td.acts { display: flex; gap: 12px; flex-wrap: wrap; }
.tbl td.acts form { margin: 0; }
.tag { font-size: 11px; background: var(--warn-bg); color: #92400e; padding: 1px 6px; border-radius: 4px; }

/* pulpit */
.publish { display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-left: 4px solid var(--gold); }
.publish p { margin: 4px 0; }
.pubform { display: flex; gap: 8px; flex-wrap: wrap; }
.pubform input { min-width: 220px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.tile:hover { border-color: var(--gold); }
.tile .n { font-size: 26px; font-weight: 700; color: var(--gold-d); }
.changes { list-style: none; padding: 0; margin: 0; }
.changes li { padding: 6px 0; border-bottom: 1px solid var(--line); }

/* listy */
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.head h1 { margin-bottom: 0; }
.crumb { font-size: 13px; text-decoration: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid #d6d0c2; border-radius: 8px; background: #fff; width: 100%; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #e9d9b3; border-color: var(--gold); }
input[type=checkbox] { width: auto; }
.filter { margin-bottom: 12px; max-width: 520px; }
.rows { list-style: none; padding: 0; margin: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
.rows li { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows .main { flex: 1; min-width: 0; padding: 11px 16px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.rows .main:hover .t { color: var(--gold-d); }
.rows .t { font-weight: 550; overflow: hidden; text-overflow: ellipsis; }
.rows .s { font-size: 13px; color: var(--muted); }
.rows .meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.rows .pv { padding: 11px 16px; text-decoration: none; }

/* formularz */
.form .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form details.adv .fields { margin-top: 14px; }
.field { min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field .lbl { display: block; font-weight: 600; font-size: 14px; margin-bottom: 5px; }
.field .req { color: var(--err); }
.field .help { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.boolf { align-self: end; }
.chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; }
textarea.code { font: 13px/1.45 ui-monospace, Consolas, monospace; }
.ref { display: flex; flex-direction: column; gap: 6px; }
.refval { display: flex; gap: 8px; align-items: center; min-height: 22px; }
.picker { position: relative; }
.picklist { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 4px 0; list-style: none; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 320px; overflow-y: auto; }
.picklist li { padding: 7px 12px; cursor: pointer; }
.picklist li:hover { background: var(--bg); }
.picklist small, .refs small { color: var(--muted); }
.refs { margin: 10px 0 0; padding: 0 0 0 28px; max-height: 480px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.refs:empty { display: none; }
.refs li { padding: 6px 8px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.refs li.missing a { color: var(--err); }
.rowbtns { margin-left: auto; display: inline-flex; gap: 4px; }
.rowbtns button, button.x { border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; padding: 2px 8px; font-size: 13px; }
.rowbtns button:disabled { opacity: .35; cursor: default; }
button.x { color: var(--err); }
.imgfield { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.imgfield img { max-width: 260px; max-height: 180px; border-radius: 8px; border: 1px solid var(--line); }
.imgfield > div { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 8px; }
.imgbtns { display: flex; gap: 8px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 10px; }
.gitem { border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.gitem img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 4px; }
.gitem input { padding: 5px 7px; font-size: 13px; }
.filefield { display: flex; gap: 6px; }
.rowsbox .row { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; background: #fcfbf8; }
.rowfields { flex: 1; display: flex; flex-wrap: wrap; gap: 10px 14px; min-width: 0; }
.rowfields .field { flex: 1 1 200px; }
.rowfields .field.narrow { flex: 0 0 110px; }
.rowfields .field.boolf { flex: 0 0 auto; align-self: center; }
.rowfields .field.wide { flex-basis: 100%; }
.rowsbox .row > .rowbtns { align-self: center; }
.menutree .mitem { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 8px; background: #fcfbf8; }
.mrow { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.mrow input { padding: 6px 8px; }
.msub { margin-left: 26px; }
.savebar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50; padding: 12px 20px; border-radius: 999px;
  background: var(--ok); color: #fff; font-weight: 600; box-shadow: 0 4px 18px rgba(0,0,0,.2); }
.savebar.err { background: var(--err); }
.danger-zone summary { color: var(--err); }
.invite { border-left: 4px solid var(--ok); }
.copyrow { display: flex; gap: 8px; }
form.inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
form.inline label { display: flex; flex-direction: column; font-size: 14px; font-weight: 600; gap: 4px; flex: 1; min-width: 200px; }
form.inline label.chk { flex-direction: row; font-weight: 400; flex: 0 1 auto; min-width: 0; }

/* logowanie */
body.auth { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
body.auth main { padding: 16px; width: 100%; max-width: 420px; }
.authbox { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px; text-align: center; }
.authlogo { height: 70px; }
.authbox h1 { margin: 10px 0 0; }
.authbox form { text-align: left; display: flex; flex-direction: column; gap: 14px; margin: 18px 0 10px; }
.authbox label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 14px; }

/* telefon */
@media (max-width: 860px) {
  .navtoggle { display: block; }
  .brand span { display: none; }
  .side { transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px rgba(0,0,0,.15); }
  body.navopen .side { transform: none; }
  main, main.with-nav { margin-left: 0; padding: 16px 16px 90px; }
  .cols, .form .fields { grid-template-columns: 1fr; }
  .top-actions .btn.ghost { display: none; }
  .rows .meta { display: none; }
  h1 { font-size: 22px; }
  .head .actions { width: 100%; }
  .head .actions .btn { flex: 1; justify-content: center; }
  .rowsbox .row { flex-direction: column; }
  .rowsbox .row .rowbtns { margin-left: 0; }
  .mrow { flex-wrap: wrap; }
  .mrow input { flex: 1 1 140px; }
  .tbl td.acts { flex-direction: column; gap: 6px; }
  .publish form, .pubform input { width: 100%; }
}

/* wybór powiązanego wpisu: jedno pole */
.combo { position: relative; display: flex; align-items: stretch; }
.combo-btn { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left;
  font: inherit; padding: 9px 11px; border: 1px solid #d6d0c2; border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer; }
.combo-btn:hover { border-color: var(--gold); }
.combo-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo .caret { color: var(--muted); font-size: 12px; }
.combo-search { flex: 1; }
.combo-open { display: flex; align-items: center; padding: 0 10px; margin-left: 6px; border: 1px solid var(--line); border-radius: 8px;
  text-decoration: none; background: #fff; }
.combo-open[hidden] { display: none; }
.picklist li.sel { background: #f3ead6; }
.picklist li.none { color: var(--muted); font-style: italic; }
