/* ═══════════════════════════════════════════════════════
   WSPÓLNY CSS — sepia / stary pergamin
═══════════════════════════════════════════════════════ */
:root {
    --ink:#2c1408; --brn:#7a4a20; --gold:#c8a060; --warm:#d4b080;
    --paper:#f7f0e2; --parch:#eee4cc; --aged:#ddd0b0; --faded:#b8a080;
    --mut:#8a6840; --lt:#fdf8f0; --red:#8b2010;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: 'Georgia', 'Times New Roman', serif;
    color: var(--ink); background: var(--parch);
    background-image: radial-gradient(circle at 1px 1px, rgba(184,160,128,.13) 1px, transparent 0);
    background-size: 28px 28px;
    min-height: 100vh;
}

/* ── NAVBAR ──────────────────────────────────────────── */
.navbar {
    display: flex; align-items: center; gap: .45rem;
    padding: .42rem 1rem; background: var(--brn); color: var(--paper);
    border-bottom: 2px solid var(--ink); flex-wrap: wrap;
    position: sticky; top: 0; z-index: 100;
}
.navbar h1 { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: .35rem; white-space: nowrap; }
.navbar h1 i { color: var(--gold); }
.nav-links  { display: flex; gap: .15rem; }
.nav-link {
    background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
    border-radius: 3px; color: rgba(255,255,255,.85); padding: .26rem .7rem;
    font-size: .78rem; cursor: pointer; text-decoration: none; font-family: Georgia, serif;
    transition: background .13s; display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap;
}
.nav-link:hover  { background: rgba(255,255,255,.2); color: #fff; }
.nav-link.active { background: rgba(255,255,255,.22); color: #fff; border-color: rgba(255,255,255,.4); font-weight: 700; }
.nb {
    background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
    border-radius: 3px; color: var(--paper); padding: .26rem .72rem;
    font-size: .78rem; cursor: pointer; font-family: Georgia, serif;
    display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap;
    transition: background .13s; text-decoration: none;
}
.nb:hover    { background: rgba(255,255,255,.22); }
.nb.primary  { background: var(--gold); color: var(--ink); border-color: var(--gold); font-weight: 700; }
.nb.primary:hover { background: #e8b840; }
#navSearch {
    border: 1px solid rgba(255,255,255,.28); border-radius: 3px;
    padding: .26rem .6rem; font-size: .8rem; outline: none;
    font-family: Georgia, serif; background: rgba(255,255,255,.1);
    color: var(--paper); width: 170px;
}
#navSearch::placeholder { color: rgba(255,255,255,.5); }
#navSearch:focus { background: rgba(255,255,255,.18); }
.nav-sep { width: 1px; height: 1rem; background: rgba(255,255,255,.22); flex-shrink: 0; }
.nav-flash { font-size: .74rem; padding: .18rem .5rem; border-radius: 3px; }
.nav-flash.ok  { background: #dcf0e0; color: #1a4828; }
.nav-flash.err { background: #f5dce8; color: #581a30; }

/* ── PAGE ────────────────────────────────────────────── */
.page { max-width: 1320px; margin: 0 auto; padding: 1rem 1.2rem; }

/* ── PANEL ───────────────────────────────────────────── */
.panel { background: var(--lt); border: 1.5px solid var(--warm); border-radius: 4px; box-shadow: 2px 2px 0 var(--aged); overflow: hidden; margin-bottom: 1rem; }
.panel-hdr {
    display: flex; align-items: center; gap: .4rem;
    padding: .38rem .8rem; background: var(--parch);
    border-bottom: 1.5px solid var(--aged);
    font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--mut);
}
.panel-hdr i { color: var(--gold); font-size: .88rem; }

/* ── STATS ───────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(4,1fr); border-bottom: 1px solid var(--aged); }
.stat { text-align: center; padding: .6rem .3rem; border-right: 1px solid var(--aged); }
.stat:last-child { border-right: none; }
.stat .n { font-size: 1.4rem; font-weight: 700; color: var(--brn); line-height: 1; }
.stat .l  { font-size: .62rem; color: var(--mut); text-transform: uppercase; letter-spacing: .04em; margin-top: .15rem; }

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
    background: var(--brn); color: var(--paper); border: none; border-radius: 4px;
    padding: .38rem 1rem; font-size: .88rem; cursor: pointer; font-family: Georgia, serif;
    display: inline-flex; align-items: center; gap: .3rem;
    box-shadow: 2px 2px 0 var(--ink); transition: all .12s; text-decoration: none; white-space: nowrap;
}
.btn:hover  { background: var(--ink); }
.btn:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 var(--ink); }
.btn-sm {
    background: var(--parch); color: var(--brn); border: 1.5px solid var(--warm);
    border-radius: 3px; padding: .22rem .52rem; font-size: .75rem; cursor: pointer;
    font-family: Georgia, serif; display: inline-flex; align-items: center; gap: .22rem;
    transition: all .12s; text-decoration: none; white-space: nowrap;
}
.btn-sm:hover { background: var(--aged); }
.btn-del { border-color: #d4a090; color: var(--red); }
.btn-del:hover { background: #f5e4e0; }

/* ── MEMBER ROW ──────────────────────────────────────── */
.mrow {
    display: flex; align-items: center; gap: .55rem;
    padding: .52rem .85rem; transition: background .1s;
    border-bottom: 1px solid var(--aged);
}
.mrow:hover { background: var(--parch); }
.av {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    border: 1.5px solid var(--warm); display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .72rem; font-family: Georgia, serif;
    overflow: hidden; background: var(--aged); color: var(--brn);
}
.av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.mname { font-size: .88rem; font-weight: 700; color: var(--ink); }
.mrel  { font-size: .7rem; color: var(--mut); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 500px; }
.mact  { margin-left: auto; display: flex; gap: .25rem; flex-shrink: 0; }
.empty { text-align: center; padding: 3rem; color: var(--faded); font-style: italic; font-size: .9rem; }
.empty i { font-size: 2.2rem; display: block; margin-bottom: .6rem; color: var(--warm); }

/* ── OVERLAY FORMULARZ ───────────────────────────────── */
.overlay { display: none; position: fixed; inset: 0; background: rgba(44,20,8,.42); z-index: 300; overflow-y: auto; padding: 1.2rem 1rem; }
.overlay.open { display: flex; align-items: flex-start; justify-content: center; }
.mbox {
    background: var(--paper); border: 2px solid var(--warm); border-radius: 5px;
    width: 100%; max-width: 580px; margin: auto; padding: 1.55rem 1.75rem;
    position: relative; box-shadow: 5px 5px 0 rgba(44,20,8,.25);
}
.mbox-title { font-size: 1.1rem; font-weight: 700; color: var(--brn); margin-bottom: .1rem; }
.mbox-sub   { font-size: .78rem; color: var(--mut); font-style: italic; margin-bottom: .9rem; padding-bottom: .8rem; border-bottom: 2px double var(--aged); }
.mbox-x { position: absolute; top: .75rem; right: .75rem; background: none; border: none; cursor: pointer; color: var(--faded); font-size: 1.2rem; line-height: 1; transition: color .13s; }
.mbox-x:hover { color: var(--brn); }

/* ── FORM ────────────────────────────────────────────── */
.lbl { display: block; font-size: .7rem; font-weight: 700; color: var(--mut); margin-bottom: .2rem; text-transform: uppercase; letter-spacing: .05em; }
.fi  { width: 100%; border: 1.5px solid var(--warm); border-radius: 4px; padding: .38rem .62rem; font-size: .9rem; outline: none; font-family: Georgia, serif; color: var(--ink); background: var(--lt); transition: border-color .15s; }
.fi:focus { border-color: var(--brn); }
textarea.fi { resize: vertical; min-height: 60px; }
.field { margin-bottom: .72rem; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .65rem; }
.fsec { font-size: .68rem; font-weight: 700; letter-spacing: .07em; color: var(--mut); text-transform: uppercase; margin: .85rem 0 .55rem; display: flex; align-items: center; gap: .38rem; border-top: 2px double var(--aged); padding-top: .65rem; }
.fsec i { color: var(--gold); }

/* relation pills */
.rpill { border: 1.5px solid var(--warm); border-radius: 20px; padding: .28rem .85rem; font-size: .82rem; cursor: pointer; color: var(--brn); font-family: Georgia, serif; background: var(--lt); display: inline-flex; align-items: center; gap: .28rem; transition: all .13s; }
.rpill:hover { background: var(--parch); }
.rpill.on    { background: var(--brn); color: var(--paper); border-color: var(--brn); }

/* picker */
.picker-box { background: var(--parch); border: 1.5px solid var(--aged); border-radius: 4px; padding: .65rem .85rem; margin-top: .4rem; }
.picker-box label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); display: block; margin-bottom: .32rem; }
.picker-row { display: flex; gap: .3rem; }
.picker-row select { flex: 1; border: 1.5px solid var(--warm); border-radius: 4px; padding: .38rem .6rem; font-size: .88rem; font-family: Georgia, serif; color: var(--ink); background: var(--lt); outline: none; }
.picker-row select:focus { border-color: var(--brn); }

/* tags */
.tags { display: flex; flex-wrap: wrap; gap: .28rem; margin-top: .45rem; min-height: 1rem; }
.tag  { display: inline-flex; align-items: center; gap: .3rem; border-radius: 20px; padding: .18rem .62rem; font-size: .74rem; font-family: Georgia, serif; border: 1.5px solid; font-weight: 600; }
.tag-father { background: #dce8f5; color: #1a3058; border-color: #98b8d8; }
.tag-mother { background: #f5dce8; color: #581a30; border-color: #d898b8; }
.tag-spouse { background: #ede0f5; color: #3a1858; border-color: #c0a0d8; }
.tag-child  { background: #dcf0e0; color: #1a4828; border-color: #90c898; }
.tag-x { background: none; border: none; cursor: pointer; font-size: .88rem; line-height: 1; opacity: .5; padding: 0; }
.tag-x:hover { opacity: 1; }

.notice { background: #f5ece0; border: 1.5px solid var(--warm); border-radius: 4px; padding: .45rem .75rem; font-size: .78rem; color: var(--brn); margin-bottom: .8rem; display: flex; gap: .38rem; align-items: flex-start; }
.co-note { margin-top: .4rem; padding: .38rem .7rem; background: #f5ece0; border: 1px solid var(--warm); border-radius: 4px; font-size: .75rem; color: var(--brn); }
.form-footer { display: flex; gap: .45rem; justify-content: flex-end; padding-top: .75rem; border-top: 2px double var(--aged); margin-top: .65rem; }
.btn-cancel-f { background: var(--parch); color: var(--mut); border: 1.5px solid var(--warm); border-radius: 4px; padding: .4rem .95rem; font-size: .88rem; cursor: pointer; font-family: Georgia, serif; }
.btn-cancel-f:hover { background: var(--aged); }

/* ── SCROLLBAR ───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--parch); }
::-webkit-scrollbar-thumb { background: var(--aged); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--warm); }

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 600px) {
    .g2, .g3 { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: repeat(2,1fr); }
}