/* Style ekranowe aplikacji (panel administracyjny) */

:root {
    --bg: #f4f4f5;
    --fg: #1f2937;
    --muted: #6b7280;
    --border: #d1d5db;
    --primary: #1f2937;
    --primary-fg: #ffffff;
    --error-bg: #fee2e2;
    --error-fg: #991b1b;
    --card-bg: #ffffff;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: var(--primary-fg);
}

.topbar .brand {
    display: inline-flex;
    align-items: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-fg);
    text-decoration: none;
    letter-spacing: 0.02em;
}
.brand__logo {
    display: block;
    height: 3.25rem;
    width: auto;
    max-width: 280px;
    object-fit: contain;
    background: #fff;
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
}

.login-logo {
    margin: 0 0 1rem;
    text-align: center;
}
.login-logo__link {
    display: inline-block;
    line-height: 0;
}
.login-logo__img {
    display: inline-block;
    max-width: 100%;
    height: auto;
    max-height: 96px;
}
.login-card .login-head {
    text-align: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.login-head__title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--fg);
}
.login-head__subtitle {
    margin: 0.35rem 0 0;
    font-size: 0.95rem;
    color: var(--muted);
}
.login-lead { margin: 0 0 1rem; }
.login-extra { margin: 1rem 0 0; text-align: center; font-size: 0.92rem; }
.login-extra a { color: var(--primary); }
.form__hint { margin: 0; font-size: 0.82rem; color: var(--muted); }

.topnav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.topnav a { color: var(--primary-fg); text-decoration: none; }
.topnav a:hover { text-decoration: underline; }

/* Nazwa uzytkownika: ta sama wielkosc co pozycje menu (wczesniej byla mniejsza),
   przygaszona i oddzielona kreska - bo nie jest klikalna. */
.topnav__user {
    color: #cbd5e1;
    padding-left: 1.25rem;
    border-left: 1px solid rgba(255, 255, 255, 0.25);
}

/* Wyloguj: wyrozniony jako osobna akcja, nie kolejna pozycja nawigacji. */
.topnav a.topnav__logout {
    padding: 0.3rem 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 999px;
    line-height: 1.2;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.topnav a.topnav__logout:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #fff;
    text-decoration: none;
}

.container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.container--wide {
    max-width: 1200px;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.search-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.search-bar__field {
    flex: 1 1 16rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}
.search-bar__field--date {
    flex: 0 1 11rem;
}
.search-bar__label {
    font-size: 0.85rem;
    color: var(--muted);
}
.search-bar__input {
    width: 100%;
}
.search-bar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.search-bar__info {
    margin: -0.5rem 0 1rem;
    font-size: 0.95rem;
}

/* Warstwa wizytowki tla w panelu admina. Te same klasy co przy wydruku (template.css),
   ale template.css nadpisuje <body>, wiec na stronach panelu powtarzamy je tutaj. */
.bg-card { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.bg-card__text { position: absolute; line-height: 1.25; box-sizing: border-box; }
.bg-card__img { position: absolute; height: auto; display: block; }

/* Podglad wizytowki na tle (okno "Tla klepsydry"): kartka 297x210mm skalowana
   transformacja do rozmiaru podgladu, zeby bloki mogly uzywac milimetrow. */
.bg-cardlayer { position: absolute; inset: 0; overflow: hidden; }
.bg-cardlayer__sheet {
    position: absolute; top: 0; left: 0;
    width: 297mm; height: 210mm;
    transform-origin: top left;
}
/* Obrys i chwytanie tylko w podgladzie edycji - miniaturki maja byc czyste. */
.bg-cardlayer--edit .bg-card__text,
.bg-cardlayer--edit .bg-card__img { outline: 1px dashed #94a3b8; cursor: move; pointer-events: auto; }
.bg-cardlayer--edit:hover .bg-card__text,
.bg-cardlayer--edit:hover .bg-card__img { outline-color: #2563eb; }

/* Miniaturka tla na liscie - z nalozona wizytowka, zeby od razu bylo widac efekt. */
.bg-thumbwrap { position: relative; display: inline-block; width: 96px; height: 68px; }
.bg-thumbwrap .bg-thumb { display: block; }

/* Miniaturka wizytowki na jej liscie - wieksza, bo pokazuje rozklad blokow. */
.card-thumb {
    position: relative;
    display: inline-block;
    width: 170px;
    height: 120px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.card-thumb__bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: fill; display: block; }

/* --- Generator wizytowek dla tel --- */
.cardgen { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: flex-start; }
.cardgen__preview { flex: 1 1 26rem; min-width: 0; }
.cardgen__panel { flex: 0 1 20rem; min-width: 0; }
.cardgen__add { display: flex; gap: 0.4rem; margin-bottom: 0.75rem; }
.cardgen__add .btn { flex: 1 1 auto; font-weight: 600; }
.cardgen__add #addText { background: #0d9488; border-color: #0d9488; color: #fff; }
.cardgen__add #addImage { background: #7c3aed; border-color: #7c3aed; color: #fff; }

/* Kartka A4 (poziomo). Ma REALNE wymiary 297x210mm i jest pomniejszana transformacja
   (skala liczona w JS) - dzieki temu bloki moga uzywac milimetrow tak samo jak na wydruku. */
.cardgen__sheetwrap { width: 100%; overflow: hidden; }
.cardgen__sheet {
    position: relative;
    width: 297mm;
    height: 210mm;
    transform-origin: top left;
    background: #fff no-repeat center / 100% 100%;
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}
.cardgen__sheet .bg-card { pointer-events: none; }
.cardgen__sheet .bg-card__text,
.cardgen__sheet .bg-card__img { outline: 1px dashed #94a3b8; }
.cardgen__sheet .bg-card__text:hover,
.cardgen__sheet .bg-card__img:hover { outline: 2px solid #2563eb; }

/* Kolory kart odpowiadaja przyciskom dodawania: tekst = morski, grafika = fioletowy. */
.bc-card { border-left: 4px solid var(--border); }
.bc-card--text  { border-left-color: #0d9488; background: rgba(13, 148, 136, 0.07); }
.bc-card--image { border-left-color: #7c3aed; background: rgba(124, 58, 237, 0.07); }
.bc-card legend { display: flex; align-items: center; gap: 0.3rem; font-weight: 600; }
.bc-card--text legend  { color: #0f766e; }
.bc-card--image legend { color: #6d28d9; }
.bc-text {
    width: 100%; box-sizing: border-box;
    border: 1px solid var(--border); border-radius: 6px;
    padding: 0.4rem 0.5rem; font-family: inherit; font-size: 0.9rem; resize: vertical;
}

/* Wiersz "etykieta - kontrolka" i przelaczniki stylu/wyrownania. Te same wzorce co
   w edytorze klepsydry, ale builder.css nadpisuje .btn i .muted, wiec nie mozna go tu
   wczytac - powtarzamy potrzebne reguly zawezone do generatora. */
.cardgen .sec__row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.5rem; margin-top: 0.45rem; font-size: 0.85rem; color: #374151;
}
.cardgen .font-row { display: flex; align-items: center; gap: 0.3rem; flex: 1 1 auto; min-width: 0; justify-content: flex-end; }
.cardgen .font-select { font-size: 0.82rem; padding: 0.2rem; flex: 1 1 auto; min-width: 0; }
.cardgen .font-row input[type="number"] { width: 56px; padding: 0.2rem 0.3rem; }
.cardgen .font-unit { font-size: 0.78rem; color: var(--muted); }

.cardgen .style-group,
.cardgen .align-group { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.cardgen .style-btn,
.cardgen .align-btn { position: relative; margin: 0; }
.cardgen .style-btn input,
.cardgen .align-btn input { position: absolute; top: 0; left: 0; opacity: 0; pointer-events: none; }
.cardgen .style-btn span,
.cardgen .align-btn span {
    display: inline-block; width: 28px; text-align: center; padding: 0.25rem 0;
    cursor: pointer; font-size: 0.82rem; color: #374151; background: #fff;
    border-left: 1px solid var(--border);
}
.cardgen .style-btn:first-child span,
.cardgen .align-btn:first-child span { border-left: none; }
.cardgen .style-btn input:checked + span,
.cardgen .align-btn input:checked + span { background: #1f2937; color: #fff; }

/* Kolor i tlo pola - kontrolki wyrownane do prawej, jak pozostale wiersze */
.cardgen input[type="color"] {
    width: 46px; height: 26px; padding: 0; border: 1px solid var(--border);
    border-radius: 4px; background: #fff; cursor: pointer;
}
.cardgen .sec__img { margin-top: 0.45rem; }
.cardgen .file-btn {
    display: inline-block; padding: 0.3rem 0.6rem; border: 1px solid var(--border);
    border-radius: 6px; background: #fff; cursor: pointer; font-size: 0.82rem;
}
.cardgen .file-btn:hover { background: #f3f4f6; }
.cardgen .file-btn input { display: none; }
.cardgen .file-status { font-size: 0.78rem; margin-left: 0.4rem; }
/* Pola liczbowe (pozycja/szerokosc) - jeden rzad, wezsze niz domyslne */
.bc-nums {
    display: flex; flex-wrap: wrap; gap: 0.4rem;
    margin-top: 0.5rem; padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);   /* neutralna - pasuje do obu kolorow kart */
}
.bc-num { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.72rem; color: var(--muted); }
.bc-num input {
    width: 4.6rem; padding: 0.2rem 0.3rem;
    border: 1px solid var(--border); border-radius: 6px; box-sizing: border-box;
}
.bc-fill { display: inline-flex; align-items: center; gap: 0.4rem; }
.bc-chk { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.8rem; color: var(--muted); }
.bc-thumb img.thumb { max-width: 100%; max-height: 70px; }

/* Strzalki zmiany kolejnosci w tabelach slownikow/szablonow */
.dict-order { white-space: nowrap; }
.dict-order .inline-form { display: inline; }
.dict-order .link-btn { font-size: 1.05rem; line-height: 1; padding: 0 0.2rem; }
.dict-order .link-btn:disabled { color: #cbd5e1; cursor: default; }

/* Prosty wykres slupkowy (statystyki) - bez zaleznosci zewnetrznych */
.chart {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    margin: 0.75rem 0 1rem;
    overflow-x: auto;
}
.chart__col {
    flex: 1 1 0;
    min-width: 32px;
    display: flex;
    flex-direction: column;
}
.chart__track {
    height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.chart__val { font-size: 0.72rem; color: var(--muted); margin-bottom: 2px; }
.chart__bar {
    width: 100%;
    max-width: 44px;
    background: #2563eb;
    border-radius: 4px 4px 0 0;
    transition: height 0.3s ease;
}
.chart__label {
    text-align: center;
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 0.35rem;
    white-space: nowrap;
}

h1 { margin-top: 0; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}

.card--narrow {
    max-width: 380px;
    margin: 3rem auto;
}

.form { display: flex; flex-direction: column; gap: 1rem; }
.form__label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); }
.form__input {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    color: var(--fg);
}
.form__input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.form__actions { display: flex; gap: 0.75rem; align-items: center; }

.pass-row { display: flex; gap: 0.5rem; align-items: stretch; }
.pass-row .form__input { flex: 1; }

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--fg);
    text-decoration: none;
    font-size: 0.95rem;
    cursor: pointer;
}
.btn:hover { background: #f9fafb; }
.btn--primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn--primary:hover { background: #374151; border-color: #374151; color: #fff; }
.btn--sm { padding: 0.3rem 0.6rem; font-size: 0.82rem; }
.btn--accent { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn--accent:hover { background: #15803d; border-color: #15803d; color: #fff; }

.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.mail-debug {
    background: #111827;
    color: #e5e7eb;
    font-size: 0.78rem;
    line-height: 1.4;
    padding: 1rem;
    border-radius: 8px;
    overflow: auto;
    max-height: 28rem;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0 0 1.25rem;
}
.alert--error { background: var(--error-bg); color: var(--error-fg); }
.alert--ok { background: #dcfce7; color: #166534; }
.alert--info { background: #e0f2fe; color: #075985; }

.bg-thumb { width: 96px; height: 68px; object-fit: cover; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.bg-margins { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1rem; }
.margin-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

/* Podglad tla z marginesami - proporcje A4 poziomo (210/297 = 70.707%) */
.bg-preview {
    position: relative;
    width: 100%;
    padding-bottom: 70.707%;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    background: #f3f4f6;
    margin: 0.5rem 0;
    user-select: none;
}
.bg-preview[hidden] { display: none; }
.bg-preview img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: fill; display: block; pointer-events: none; }
/* Linie marginesow (przerywane, migajace) - szeroka strefa chwytu, cienka linia w srodku */
.bg-mline { position: absolute; z-index: 2; }
.bg-mline--v { top: 0; bottom: 0; width: 12px; margin-left: -6px; cursor: ew-resize; }
.bg-mline--h { left: 0; right: 0; height: 12px; margin-top: -6px; cursor: ns-resize; }
.bg-mline--v::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 2px dashed #ef4444; }
.bg-mline--h::after { content: ''; position: absolute; top: 50%; left: 0; right: 0; border-top: 2px dashed #ef4444; }
@keyframes bgMlineBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.bg-mline::after { animation: bgMlineBlink 1s linear infinite; }
.alert ul { margin: 0; padding-left: 1.2rem; }

.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 0.65rem 1rem; border-bottom: 1px solid var(--border); }
.table th { background: #f9fafb; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.table tr:last-child td { border-bottom: none; }
.table__actions { white-space: nowrap; }
.table__num { width: 4.5rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.table--logs .table__dt,
.table--logs .table__user,
.table--logs .table__result,
.table--logs .table__ip,
.table--logs .table__num {
    white-space: nowrap;
}
.table--logs .table__host { min-width: 14rem; }

.table--klepsydry .table__dt,
.table--klepsydry .table__creator {
    white-space: nowrap;
}
.table--klepsydry .table__actions {
    min-width: 15.5rem;
    vertical-align: top;
}
.table__actions a { margin-right: 0.75rem; color: #2563eb; text-decoration: none; }
.table__actions a:visited { color: #2563eb; }
.table__actions a:hover { color: #1d4ed8; text-decoration: underline; }

/* Kompaktowe przyciski akcji w tabeli klepsydr - siatka 3×2 */
.action-btns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
    width: 15rem;
    padding: 0.45rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.action-btns .inline-form {
    display: block;
    margin: 0;
    min-width: 0;
}
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    padding: 0.42rem 0.35rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--fg);
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    line-height: 1.2;
    white-space: nowrap;
    font-family: inherit;
    box-sizing: border-box;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.action-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    text-decoration: none;
    color: var(--fg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.action-btn--sm {
    padding: 0.28rem 0.55rem;
    font-size: 0.75rem;
}
.action-btn--accent {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}
.action-btn--accent:hover {
    background: #dbeafe;
    border-color: #60a5fa;
    color: #1e40af;
}
.action-btn--print {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #374151;
}
.action-btn--print:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #111827;
}
.action-btn--share {
    background: #ecfdf5;
    border-color: #6ee7b7;
    color: #047857;
}
.action-btn--share:hover {
    background: #d1fae5;
    border-color: #34d399;
    color: #065f46;
}
.action-btn--sms {
    background: #fff7ed;
    border-color: #fdba74;
    color: #c2410c;
}
.action-btn--sms:hover {
    background: #ffedd5;
    border-color: #fb923c;
    color: #9a3412;
}
.action-btn--email {
    background: #f5f3ff;
    border-color: #c4b5fd;
    color: #5b21b6;
}
.action-btn--email:hover {
    background: #ede9fe;
    border-color: #a78bfa;
    color: #4c1d95;
}
.action-btn--danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}
.action-btn--danger:hover {
    background: #fee2e2;
    border-color: #f87171;
    color: #991b1b;
}
.share-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.35rem;
}

.muted { color: var(--muted); }

/* --- Wybor szablonu z mini-podgladem (klepsydra_edit) --- */
.tpl-pick { position: relative; max-width: 440px; }
.tpl-pick__toggle {
    display: flex; align-items: center; gap: 0.6rem;
    border: 1px solid #d1d5db; border-radius: 6px; padding: 0.4rem 0.6rem;
    background: #fff; cursor: pointer;
}
.tpl-pick__toggle:hover { background: #f9fafb; }
.tpl-pick__toggle:focus { outline: 2px solid #93c5fd; outline-offset: 1px; }
.tpl-pick__current { display: flex; align-items: center; gap: 0.6rem; flex: 1; min-width: 0; }
.tpl-pick__name { font-size: 0.95rem; color: #1f2937; word-break: break-word; }
.tpl-pick__placeholder { color: #6b7280; }
.tpl-pick__arrow { margin-left: auto; color: #6b7280; }
.tpl-pick__menu {
    display: none; position: absolute; z-index: 40; top: 100%; left: 0; right: 0;
    max-height: 340px; overflow-y: auto; margin-top: 4px;
    background: #fff; border: 1px solid #d1d5db; border-radius: 6px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.15); padding: 4px;
}
.tpl-pick.open .tpl-pick__menu { display: block; }
.tpl-pick__item {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 5px 6px; border-radius: 4px; cursor: pointer;
}
.tpl-pick__item:hover, .tpl-pick__item:focus { background: #eef2ff; outline: none; }
.tpl-pick__item.is-active { background: #e0e7ff; }
.tpl-pick__error { color: #b91c1c; font-size: 0.85rem; margin: 0.35rem 0 0; }

/* Mini-podglad A4 (uklad + tlo); skala 0.15, box-sizing:border-box jest globalny */
.tpl-thumb {
    width: 169px; height: 119px; flex: none;
    overflow: hidden; border: 1px solid #d1d5db; border-radius: 3px; background: #fff;
}
.tpl-thumb__sheet {
    display: block; width: 297mm; height: 210mm;
    transform: scale(0.15); transform-origin: top left; background: #fff;
}
.tpl-thumb .frame {
    border: 3px solid #000; height: 210mm; padding: 15mm 21mm;
    display: flex; flex-direction: column; justify-content: center;
}
.tpl-thumb .ksections { display: flex; flex-direction: column; gap: 8mm; width: 100%; font-size: 24pt; }
.tpl-thumb .ksection--text { line-height: 1.4; }
.tpl-thumb .ksection--image img { display: inline-block; max-width: 100%; height: auto; }
.tpl-thumb .ksection__placeholder { color: #9ca3af; font-style: italic; }
.tpl-thumb .ksections--fill { flex: 1 1 0; min-height: 0; gap: 0; height: 100%; }
.tpl-thumb .ksections--fill .ksection { overflow: hidden; display: flex; flex-direction: column; justify-content: center; min-height: 0; flex: 1 1 0; }

/* Modal (np. wysylka SMS) */
body.modal-open { overflow: hidden; }
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal[hidden] { display: none !important; }
.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}
.modal__box {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: 0;
    z-index: 1;
}
.modal__box h2 { margin-top: 0; }

.dict-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; }
.dict-links__count { font-weight: normal; opacity: 0.85; }

/* Pasek szybkich linkow - celowo ciemny, zeby odcinal sie od bialych kart ponizej.
   Strzalka w dol = przewiniecie do sekcji na tej stronie, strzalka w prawo = inna strona. */
.quick-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
    padding: 0.7rem 0.9rem;
    background: #1f2937;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}
.quick-links__label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #9ca3af;
    margin-right: 0.35rem;
}
.quick-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.34rem 0.7rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    color: #e5e7eb;
    font-size: 0.85rem;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.quick-link:visited { color: #e5e7eb; }
.quick-link:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
}
.quick-link__ico { font-size: 0.9em; opacity: 0.55; }
.quick-link:hover .quick-link__ico { opacity: 1; }
/* Pozycje prowadzace na inna strone wyrozniamy akcentem */
.quick-link--go {
    background: rgba(96, 165, 250, 0.16);
    border-color: rgba(96, 165, 250, 0.45);
    color: #dbeafe;
}
.quick-link--go:visited { color: #dbeafe; }
.quick-link--go:hover {
    background: rgba(96, 165, 250, 0.3);
    border-color: #93c5fd;
    color: #fff;
}

/* Kotwica nie chowa naglowka pod krawedzia okna */
.card[id] { scroll-margin-top: 1rem; }
html { scroll-behavior: smooth; }

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}
.pager__info { color: var(--muted); font-size: 0.95rem; }

.share-link { font-size: 0.8rem; margin: 0.25rem 0; word-break: break-all; }
.views { font-size: 0.8rem; color: var(--muted); margin-top: 0.35rem; }

.sitefooter { text-align: center; color: var(--muted); padding: 2rem 0; }

/* --- Edytor szablonow --- */

.card + .card { margin-top: 1.5rem; }
.card h2 { margin-top: 0; }
.card > .form--inline + .table,
.card > .form--inline + .table-scroll,
.card > .form--inline + .muted { margin-top: 1rem; }

/* Szeroka tabela nie rozpycha karty - w razie potrzeby przewijamy ja poziomo */
.table-scroll { overflow-x: auto; }
.table-scroll > .table { margin: 0; }
/* W tabelach admina pozwalamy zawinac akcje (kolumna wezsza), pojedyncze linki bez lamania */
.table-scroll .table__actions { white-space: normal; }
.table-scroll .table__actions a,
.table-scroll .table__actions .link-btn { white-space: nowrap; }

/* Formularz w jednej linii (np. dodawanie / zmiana nazwy) */
.form--inline {
    flex-direction: row;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.form--inline .form__input { min-width: 220px; }

/* Maly formularz osadzony w komorce akcji */
.inline-form { display: inline; margin: 0; }

/* Przycisk wygladajacy jak link (akcje w tabeli) */
.link-btn {
    background: none;
    border: none;
    padding: 0;
    margin-right: 0.5rem;
    color: #2563eb;
    cursor: pointer;
    font-size: 0.95rem;
}
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { color: #cbd5e1; cursor: default; text-decoration: none; }
.link-btn--danger { color: #b91c1c; }

@keyframes sms-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.45; }
}
@media (prefers-reduced-motion: no-preference) {
    .action-btn--sms {
        animation: sms-blink 1.6s ease-in-out infinite;
    }
    .action-btn--sms:hover {
        animation: none;
        opacity: 1;
    }
}

/* Odznaki typu sekcji */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge--text { background: #e0e7ff; color: #3730a3; }
.badge--image { background: #dcfce7; color: #166534; }
.badge--danger { background: #fee2e2; color: #991b1b; }
.badge--default { background: #dcfce7; color: #166534; }

/* Miniatury obrazkow */
.thumb { max-height: 48px; max-width: 120px; border: 1px solid var(--border); border-radius: 4px; vertical-align: middle; }
.thumb--lg { max-height: 160px; max-width: 320px; }
.section-preview { max-width: 320px; }

/* Podpowiedz ze zmiennymi */
.hint { background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem 1rem; font-size: 0.9rem; }
.var-list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.var-list__sep { margin: 0.75rem 0 0; padding-top: 0.75rem; border-top: 1px solid var(--border); font-size: 0.85rem; font-weight: 600; }
.var-list code { background: #eef2ff; padding: 0.1rem 0.35rem; border-radius: 4px; }
