/* ==========================================================================
   Generator certyfikatów PP-MAC — system wizualny
   Kierunek: „papier wartościowy” — granat PP-MAC, złoto pieczęci, gilosz jako ornament.
   ========================================================================== */

@font-face {
  font-family: "Sora";
  src: url("../fonts/Sora-Variable.ttf") format("truetype");
  font-weight: 300 800;
  font-display: swap;
}
@font-face {
  font-family: "Be Vietnam Pro";
  src: url("../fonts/BeVietnamPro-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Be Vietnam Pro";
  src: url("../fonts/BeVietnamPro-Medium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Be Vietnam Pro";
  src: url("../fonts/BeVietnamPro-SemiBold.ttf") format("truetype");
  font-weight: 600 700;
  font-display: swap;
}

:root {
  --navy-950: #061433;
  --navy-900: #071b4a;
  --navy-800: #00355d;
  --navy-700: #0b4a7a;
  --navy-600: #1d6299;
  --navy-100: #e3edf7;
  --navy-50: #f1f6fb;

  --ink: #1d2230;
  --ink-2: #262b35;
  --muted: #5d6573;
  --muted-2: #868d98;
  --line: #dde3ec;
  --line-strong: #c6cfdc;

  --paper: #ffffff;
  --paper-2: #fbfcfe;
  --canvas: #f3f6fa;

  --gold: #b8913a;
  --gold-2: #d8b864;
  --gold-50: #faf4e4;

  --ok: #17734a;
  --ok-50: #e7f5ee;
  --warn: #8a5a00;
  --warn-50: #fff4dc;
  --err: #b42318;
  --err-50: #fdecea;
  --info: var(--navy-700);

  --radius-s: 6px;
  --radius: 10px;
  --radius-l: 16px;
  --shadow-1: 0 1px 2px rgba(7, 27, 74, .06), 0 1px 1px rgba(7, 27, 74, .04);
  --shadow-2: 0 6px 20px -8px rgba(7, 27, 74, .18), 0 2px 6px rgba(7, 27, 74, .06);
  --shadow-paper: 0 24px 48px -24px rgba(7, 27, 74, .35), 0 2px 8px rgba(7, 27, 74, .08);
  --focus: 0 0 0 3px rgba(216, 184, 100, .55), 0 0 0 1px var(--navy-800);

  --font-display: "Sora", "Be Vietnam Pro", ui-sans-serif, sans-serif;
  --font-body: "Be Vietnam Pro", ui-sans-serif, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;

  --header-h: 64px;
  --content-w: 1240px;

  /* Gilosz — subtelny ornament z cienkich linii (inline SVG jako obraz danych). */
  --guilloche: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='120' viewBox='0 0 240 120'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.07' stroke-width='.8'%3E%3Cpath d='M0 60 Q30 10 60 60 T120 60 T180 60 T240 60'/%3E%3Cpath d='M0 60 Q30 110 60 60 T120 60 T180 60 T240 60'/%3E%3Cpath d='M0 40 Q30 0 60 40 T120 40 T180 40 T240 40'/%3E%3Cpath d='M0 80 Q30 120 60 80 T120 80 T180 80 T240 80'/%3E%3Cpath d='M0 20 Q30 -10 60 20 T120 20 T180 20 T240 20'/%3E%3Cpath d='M0 100 Q30 130 60 100 T120 100 T180 100 T240 100'/%3E%3C/g%3E%3C/svg%3E");
  --guilloche-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='160' viewBox='0 0 320 160'%3E%3Cg fill='none' stroke='%231d6299' stroke-opacity='.06' stroke-width='.7'%3E%3Cpath d='M0 80 Q40 10 80 80 T160 80 T240 80 T320 80'/%3E%3Cpath d='M0 80 Q40 150 80 80 T160 80 T240 80 T320 80'/%3E%3Cpath d='M0 50 Q40 -10 80 50 T160 50 T240 50 T320 50'/%3E%3Cpath d='M0 110 Q40 170 80 110 T160 110 T240 110 T320 110'/%3E%3C/g%3E%3C/svg%3E");
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--navy-900); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); font-weight: 650; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: var(--navy-700); text-underline-offset: 2px; }
a:hover { color: var(--navy-900); }
code { font-family: var(--font-mono); font-size: .9em; background: var(--navy-50); padding: .1em .35em; border-radius: 4px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-s); }
::selection { background: var(--gold-2); color: var(--navy-950); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--gold-2); color: var(--navy-950);
  padding: 8px 14px; border-radius: var(--radius-s); font-weight: 600; text-decoration: none; transition: top .15s;
}
.skip-link:focus { top: 12px; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Boot ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.boot img { opacity: .85; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.noscript { padding: 24px; text-align: center; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  background: var(--guilloche) repeat-x center / 240px 120px, linear-gradient(100deg, var(--navy-950), var(--navy-900) 45%, var(--navy-800));
  color: #fff;
  border-bottom: 2px solid var(--gold);
  box-shadow: 0 6px 18px -10px rgba(6, 20, 51, .6);
}
.app-header .inner { max-width: var(--content-w); margin: 0 auto; height: 100%; display: flex; align-items: center; gap: 28px; padding: 0 20px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; flex-shrink: 0; }
.brand img { height: 20px; width: auto; }
.brand span { font-family: var(--font-display); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-2); border-left: 1px solid rgba(255,255,255,.25); padding-left: 12px; }
.main-nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.main-nav a {
  color: rgba(255,255,255,.78); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; font-size: .93rem; white-space: nowrap;
  transition: background .15s, color .15s;
}
.main-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.main-nav a[aria-current="page"] { color: #fff; background: rgba(255,255,255,.12); box-shadow: inset 0 -2px 0 var(--gold-2); }
.main-nav .nav-cta { color: var(--navy-950); background: var(--gold-2); font-weight: 600; }
.main-nav .nav-cta:hover { background: #e6c97a; color: var(--navy-950); }
.user-menu { position: relative; flex-shrink: 0; }
.user-button {
  display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14);
  color: #fff; border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer;
}
.user-button:hover { background: rgba(255,255,255,.14); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: var(--navy-950); font-weight: 700; font-size: .8rem; font-family: var(--font-display);
}
.user-button .who { display: grid; text-align: left; line-height: 1.15; }
.user-button .who small { color: rgba(255,255,255,.6); font-size: .72rem; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 6px; z-index: 40;
}
.menu button, .menu a { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 6px; cursor: pointer; color: var(--ink); text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--navy-50); }

@media (max-width: 900px) {
  :root { --header-h: 108px; }
  .app-header { height: auto; }
  .app-header .inner { flex-wrap: wrap; padding: 10px 16px 6px; gap: 8px 12px; }
  .brand { flex: 1; }
  .main-nav { order: 3; flex-basis: 100%; padding-bottom: 4px; }
  .user-button { padding-right: 4px; }
  .user-button .who { display: none; }
  main.content { padding: 20px 16px 60px; }
}

/* ---------- Layout ---------- */
main.content { max-width: var(--content-w); margin: 0 auto; padding: 28px 20px 80px; }
main.content:focus { outline: none; box-shadow: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.page-head .eyebrow { display: block; font-size: .75rem; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); font-weight: 600; margin-bottom: 6px; font-family: var(--font-display); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@media (max-width: 980px) {
  .grid-2, .grid-3, .grid-sidebar { grid-template-columns: 1fr; }
}
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------- Cards ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow-1); }
.card-body { padding: 22px; }
.card-head { padding: 18px 22px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-foot { padding: 14px 22px; border-top: 1px solid var(--line); background: var(--paper-2); border-radius: 0 0 var(--radius-l) var(--radius-l); }
.section-title { display: flex; align-items: center; gap: 10px; margin: 30px 0 12px; }
.section-title h2 { margin: 0; }
.section-title::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-strong), transparent); }

/* ---------- Buttons ---------- */
.btn {
  --bg: var(--paper); --fg: var(--navy-900); --bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: 9px; border: 1px solid var(--bd);
  background: var(--bg); color: var(--fg); font-weight: 600; font-size: .93rem; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s; white-space: nowrap;
}
.btn:hover { --bg: var(--navy-50); color: var(--fg); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { --bg: var(--navy-800); --fg: #fff; --bd: var(--navy-800); box-shadow: 0 6px 14px -8px rgba(0, 53, 93, .8); }
.btn-primary:hover { --bg: var(--navy-900); --bd: var(--navy-900); color: #fff; }
.btn-gold { --bg: linear-gradient(180deg, #e2c574, var(--gold)); --fg: var(--navy-950); --bd: var(--gold); background: linear-gradient(180deg, #e2c574, var(--gold)); }
.btn-gold:hover { background: linear-gradient(180deg, #ead08a, #c39c45); color: var(--navy-950); }
.btn-ghost { --bd: transparent; --bg: transparent; }
.btn-danger { --fg: var(--err); --bd: #f2c2bd; }
.btn-danger:hover { --bg: var(--err-50); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .85rem; border-radius: 7px; }
.btn-lg { min-height: 52px; padding: 12px 22px; font-size: 1rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn .spinner { width: 16px; height: 16px; }
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.btn-sm .icon { width: 15px; height: 15px; }

/* Duże przyciski pobierania */
.download-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 760px) { .download-grid { grid-template-columns: 1fr; } }
.download {
  display: grid; grid-template-columns: 56px 1fr; gap: 4px 16px; align-items: center; text-align: left;
  padding: 20px 22px; border-radius: var(--radius-l); border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); text-decoration: none; box-shadow: var(--shadow-1); transition: border-color .15s, box-shadow .2s, transform .15s;
  position: relative; overflow: hidden;
}
.download:hover { border-color: var(--navy-600); box-shadow: var(--shadow-2); transform: translateY(-2px); color: var(--ink); }
.download .glyph { grid-row: span 2; width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; background: var(--navy-50); color: var(--navy-800); }
.download.primary .glyph { background: var(--navy-800); color: #fff; }
.download.primary { background: var(--guilloche-light) center / 320px 160px, var(--paper); border-color: var(--navy-100); }
.download strong { font-family: var(--font-display); font-size: 1.05rem; color: var(--navy-900); }
.download span { color: var(--muted); font-size: .88rem; }
.download.expired { opacity: .6; pointer-events: none; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; align-content: start; }
.field > label, .label { font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.field .hint, .hint { font-size: .83rem; color: var(--muted); margin: 0; }
.field .error-text { font-size: .85rem; color: var(--err); margin: 0; display: flex; gap: 6px; align-items: flex-start; }
.field .error-text::before { content: "⚠"; }
.req { color: var(--err); margin-left: 2px; }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], input[type="search"], input:not([type]), select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--paper);
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--navy-600); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-800); box-shadow: var(--focus); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--err); background: #fffafa; }
input[type="color"] { width: 46px; height: 38px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--paper); cursor: pointer; }
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--navy-800) 50%), linear-gradient(135deg, var(--navy-800) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
select[multiple] { background-image: none; padding: 6px; min-height: 96px; }
select[multiple] option { padding: 5px 8px; border-radius: 5px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--navy-800); flex-shrink: 0; }
.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-suffix span { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 9px 9px 0; background: var(--navy-50); color: var(--muted); font-size: .85rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; background: var(--paper); }
.segmented button { border: 0; background: none; padding: 7px 12px; cursor: pointer; font-size: .87rem; color: var(--muted); border-right: 1px solid var(--line); }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--navy-800); color: #fff; }

/* ---------- Alerts, badges ---------- */
.alert { display: flex; gap: 12px; padding: 13px 16px; border-radius: var(--radius); border: 1px solid; font-size: .93rem; align-items: flex-start; }
.alert .icon { margin-top: 2px; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert p:last-child { margin-bottom: 0; }
.alert-info { background: var(--navy-50); border-color: var(--navy-100); color: var(--navy-900); }
.alert-ok { background: var(--ok-50); border-color: #bfe3cf; color: #0f5236; }
.alert-warn { background: var(--warn-50); border-color: #f1d79c; color: #5e3d00; }
.alert-error { background: var(--err-50); border-color: #f4c1bb; color: #7a1a12; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; line-height: 1.6; }
.badge-ok { background: var(--ok-50); color: var(--ok); border-color: #c6e7d5; }
.badge-warn { background: var(--warn-50); color: var(--warn); border-color: #f1d79c; }
.badge-err { background: var(--err-50); color: var(--err); border-color: #f4c1bb; }
.badge-muted { background: #eef1f5; color: var(--muted); }
.badge-navy { background: var(--navy-50); color: var(--navy-800); border-color: var(--navy-100); }
.badge-gold { background: var(--gold-50); color: #7a5b13; border-color: #ecd9a6; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.no-dot::before { display: none; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: var(--paper-2); font-weight: 600; color: var(--muted); font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; position: sticky; top: 0; z-index: 1; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafcff; }
.table tr.excluded td { opacity: .5; }
.table tr.has-error { background: #fff8f7; }
.table td.actions { text-align: right; white-space: nowrap; }
.table input { min-height: 34px; padding: 5px 9px; border-radius: 7px; }
.table .cell-messages { margin: 4px 0 0; padding: 0; list-style: none; font-size: .8rem; }
.table .cell-messages li { display: flex; gap: 5px; }
.table .cell-messages .e { color: var(--err); }
.table .cell-messages .w { color: var(--warn); }
.table a.row-link { color: var(--navy-900); font-weight: 600; text-decoration: none; }
.table a.row-link:hover { text-decoration: underline; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--navy-900); font-family: var(--font-display); font-size: 1.05rem; margin-bottom: 4px; }

/* ---------- Tabs / filters ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 9px 12px; border-bottom: 2px solid transparent; cursor: pointer; color: var(--muted); font-weight: 600; font-size: .9rem; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--navy-900); border-bottom-color: var(--gold); }
.tabs .count { font-weight: 500; color: var(--muted-2); margin-left: 4px; }

/* ---------- Stepper ---------- */
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 0 0 24px; padding: 0; list-style: none; counter-reset: step; }
.stepper li { position: relative; }
.stepper button {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: none; border: 0; cursor: pointer; text-align: left; border-bottom: 3px solid var(--line);
  color: var(--muted);
}
.stepper .dot {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  border: 1.5px solid var(--line-strong); background: var(--paper); font-family: var(--font-display); font-weight: 600; font-size: .9rem; color: var(--muted);
}
.stepper .txt { display: grid; line-height: 1.25; }
.stepper .txt strong { color: var(--ink-2); font-size: .93rem; }
.stepper .txt small { font-size: .78rem; }
.stepper [aria-current="step"] { border-bottom-color: var(--navy-800); }
.stepper [aria-current="step"] .dot { background: var(--navy-800); color: #fff; border-color: var(--navy-800); box-shadow: 0 0 0 4px var(--navy-100); }
.stepper .done .dot { background: var(--ok-50); border-color: #9fd3b8; color: var(--ok); }
.stepper .problem .dot { background: var(--err-50); border-color: #f4c1bb; color: var(--err); }
@media (max-width: 760px) {
  .stepper { grid-template-columns: repeat(4, auto); overflow-x: auto; }
  .stepper .txt small { display: none; }
}

/* ---------- Wizard layout ---------- */
.wizard { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.wizard.wide { grid-template-columns: minmax(0, 1fr); }
.wizard.wide .summary-card { display: none; }
.participants-table td { min-width: 0; }
.participants-table td.name-cell input { min-width: 150px; }
.participants-table td.override-cell input { min-width: 190px; }
.participants-table td.status-cell { min-width: 230px; max-width: 320px; }
@media (max-width: 1060px) { .wizard { grid-template-columns: 1fr; } }
.summary-card { position: sticky; top: calc(var(--header-h) + 20px); }
.summary-list { display: grid; gap: 10px; margin: 0; }
.summary-list div { display: grid; grid-template-columns: 110px 1fr; gap: 8px; font-size: .9rem; }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.save-state { font-size: .82rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.save-state.saving::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); animation: pulse 1s infinite; }
.save-state.saved::before { content: "✓"; color: var(--ok); font-weight: 700; }
.save-state.error { color: var(--err); }

/* Szablony do wyboru */
.template-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.template-option { position: relative; border: 1.5px solid var(--line); border-radius: var(--radius); padding: 10px; background: var(--paper); cursor: pointer; text-align: left; display: grid; gap: 8px; transition: border-color .15s, box-shadow .15s; }
.template-option:hover { border-color: var(--navy-600); }
.template-option[aria-checked="true"] { border-color: var(--navy-800); box-shadow: 0 0 0 3px var(--navy-100); }
.template-option[aria-checked="true"]::after { content: "✓"; position: absolute; top: 14px; right: 14px; width: 24px; height: 24px; border-radius: 50%; background: var(--navy-800); color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.template-option .thumb { aspect-ratio: 210 / 297; background: var(--navy-50); border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.template-option .thumb img, .template-option .thumb canvas { width: 100%; height: 100%; object-fit: cover; }
.template-option strong { font-size: .9rem; color: var(--navy-900); }
.template-option small { color: var(--muted); }

/* Tytuł — podgląd z cudzysłowami */
.title-preview { margin-top: 8px; padding: 12px 16px; border-radius: var(--radius); background: var(--paper-2); border: 1px dashed var(--line-strong); font-family: "Montserrat-SBI", var(--font-display); font-style: italic; font-weight: 600; font-size: 1.15rem; color: var(--ink); text-align: center; white-space: pre-line; }
.title-preview small { display: block; font-family: var(--font-body); font-style: normal; font-weight: 400; font-size: .75rem; color: var(--muted); margin-bottom: 4px; letter-spacing: .06em; text-transform: uppercase; }

/* ---------- Import z Excela ---------- */
.paste-zone { position: relative; }
.paste-zone textarea { min-height: 170px; font-family: var(--font-mono); font-size: .85rem; background: var(--guilloche-light) center / 320px 160px, var(--paper); border-style: dashed; border-width: 1.5px; }
.paste-zone .paste-hint { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; color: var(--muted); gap: 6px; }
.paste-zone .paste-hint strong { color: var(--navy-900); font-family: var(--font-display); font-size: 1.05rem; }
.paste-zone .paste-hint kbd { font-family: var(--font-mono); background: var(--paper); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; font-size: .8rem; }
.mapping { display: grid; gap: 14px; }
.mapping-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.mapping-col { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--paper-2); display: grid; gap: 8px; }
.mapping-col .samples { margin: 0; padding: 0; list-style: none; font-size: .84rem; color: var(--muted); }
.mapping-col .samples li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Podgląd PDF ---------- */
.preview-stage {
  background: radial-gradient(ellipse at top, #eaf0f7, #dfe6ef); border-radius: var(--radius-l); padding: 26px; display: grid; place-items: center; min-height: 420px; position: relative;
  border: 1px solid var(--line);
}
.preview-stage canvas, .preview-stage .paper { box-shadow: var(--shadow-paper); background: #fff; border-radius: 2px; max-width: 100%; height: auto; }
.preview-stage .placeholder { color: var(--muted); text-align: center; max-width: 340px; }
.preview-stage .loading-veil { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(243, 246, 250, .7); border-radius: var(--radius-l); }
.preview-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }

/* ---------- Postęp ---------- */
.progress { height: 12px; border-radius: 999px; background: var(--navy-50); overflow: hidden; border: 1px solid var(--navy-100); }
.progress > span { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--navy-700), var(--navy-800), var(--gold)); background-size: 200% 100%; transition: width .4s ease; animation: shimmer 2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.progress-card { text-align: center; padding: 40px 24px; }
.progress-card .big { font-family: var(--font-display); font-size: 2rem; font-weight: 650; color: var(--navy-900); }
.stage-list { display: flex; justify-content: center; gap: 22px; margin-top: 18px; flex-wrap: wrap; list-style: none; padding: 0; font-size: .87rem; color: var(--muted); }
.stage-list li.done { color: var(--ok); }
.stage-list li.current { color: var(--navy-900); font-weight: 600; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--navy-100); border-top-color: var(--navy-800); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Dashboard ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 22px; padding: 38px 40px; color: #fff;
  background: var(--guilloche) center / 240px 120px, radial-gradient(circle at 85% 20%, rgba(216, 184, 100, .25), transparent 40%), linear-gradient(120deg, var(--navy-950), var(--navy-800));
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 30px; align-items: center; box-shadow: var(--shadow-2);
}
.hero h1 { color: #fff; font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.3rem); margin-bottom: 8px; }
.hero p { color: rgba(255,255,255,.78); max-width: 560px; margin: 0; }
.hero .eyebrow { color: var(--gold-2); letter-spacing: .18em; text-transform: uppercase; font-size: .75rem; font-weight: 600; font-family: var(--font-display); display: block; margin-bottom: 10px; }
.hero .seal {
  width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; text-align: center;
  background: radial-gradient(circle at 35% 30%, #f3dc98, var(--gold) 55%, #8c6a22); color: var(--navy-950);
  box-shadow: 0 0 0 6px rgba(216, 184, 100, .25), 0 0 0 7px rgba(216, 184, 100, .5), 0 14px 30px -10px rgba(0,0,0,.5);
  font-family: var(--font-display); font-weight: 700; line-height: 1.1;
}
.hero .seal small { display: block; font-size: .65rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; }
.hero .seal b { font-size: 1.9rem; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; padding: 28px 24px; } .hero .seal { display: none; } }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 20px; }
.stat { padding: 16px 18px; border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line); }
.stat b { display: block; font-family: var(--font-display); font-size: 1.5rem; color: var(--navy-900); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }
@media (max-width: 760px) { .stat-row { gap: 8px; } .stat { padding: 12px; } .stat b { font-size: 1.2rem; } .stat span { font-size: .75rem; } }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain > li { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--line); }
.list-plain > li:last-child { border-bottom: 0; }
.list-plain .meta { color: var(--muted); font-size: .85rem; }

/* ---------- Edytor szablonu ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; position: sticky; top: calc(var(--header-h) + 8px); z-index: 5; }
.editor-stage { background: repeating-conic-gradient(#e9eef5 0% 25%, #f2f5f9 0% 50%) 50% / 22px 22px; border-radius: var(--radius-l); padding: 30px; overflow: auto; border: 1px solid var(--line); }
.page-canvas { position: relative; margin: 0 auto; background: #fff; box-shadow: var(--shadow-paper); user-select: none; touch-action: none; }
.page-canvas .bg { position: absolute; pointer-events: none; }
.page-canvas .guide { position: absolute; pointer-events: none; z-index: 3; }
.page-canvas .guide.v { top: 0; bottom: 0; width: 0; border-left: 1px dashed #d23c8a; }
.page-canvas .guide.h { left: 0; right: 0; height: 0; border-top: 1px dashed #d23c8a; }
.page-canvas.show-grid::before { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background-image: linear-gradient(rgba(29, 98, 153, .12) 1px, transparent 1px), linear-gradient(90deg, rgba(29, 98, 153, .12) 1px, transparent 1px);
  background-size: var(--grid, 37.8px) var(--grid, 37.8px); }
.fbox { position: absolute; z-index: 2; border: 1.5px dashed rgba(29, 98, 153, .85); background: rgba(227, 237, 247, .28); cursor: move; display: flex; overflow: visible; border-radius: 2px; }
.fbox:hover { background: rgba(227, 237, 247, .45); }
.fbox.selected { border-style: solid; border-color: var(--gold); background: rgba(250, 244, 228, .35); box-shadow: 0 0 0 1px rgba(184, 145, 58, .4); z-index: 4; }
.fbox:focus-visible { box-shadow: var(--focus); }
.fbox .ftext { width: 100%; display: flex; flex-direction: column; white-space: pre; line-height: 1.2; color: #000; pointer-events: none; overflow: visible; }
.fbox .ftag { position: absolute; left: -1.5px; bottom: 100%; background: rgba(29, 98, 153, .92); color: #fff; font-size: 10.5px; padding: 1px 6px; border-radius: 3px 3px 0 0; white-space: nowrap; font-family: var(--font-body); font-weight: 600; pointer-events: none; }
.fbox.selected .ftag { background: var(--gold); color: var(--navy-950); }
.fbox.overflow { border-color: var(--err); background: rgba(253, 236, 234, .45); }
.fbox.overflow .ftag { background: var(--err); color: #fff; }
.fbox .handle { position: absolute; width: 11px; height: 11px; background: #fff; border: 1.5px solid var(--gold); border-radius: 2px; display: none; }
.fbox.selected .handle { display: block; }
.fbox .handle.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.fbox .handle.e { right: -6px; top: calc(50% - 5px); cursor: ew-resize; }
.fbox .handle.s { bottom: -6px; left: calc(50% - 5px); cursor: ns-resize; }
.fbox .handle.w { left: -6px; top: calc(50% - 5px); cursor: ew-resize; }
.fbox .handle.n { top: -6px; left: calc(50% - 5px); cursor: ns-resize; }
.inspector { position: sticky; top: calc(var(--header-h) + 8px); max-height: calc(100vh - var(--header-h) - 24px); overflow: auto; }
.inspector .card-body { padding: 18px; }
.inspector .grid-2 { gap: 10px 12px; }
.inspector h3 { font-size: .95rem; }
.field-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.field-list button { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; text-align: left; font-size: .88rem; }
.field-list button[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-50); }
.kbd-hint { font-size: .78rem; color: var(--muted); }
.kbd-hint kbd { font-family: var(--font-mono); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--paper); }
.versions { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; max-height: 280px; overflow: auto; }
.versions li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: .86rem; }
.versions li.current { border-color: var(--navy-600); background: var(--navy-50); }

/* Karty szablonów */
.template-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.template-card { overflow: hidden; display: grid; text-decoration: none; color: var(--ink); transition: transform .15s, box-shadow .2s; }
.template-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); color: var(--ink); }
.template-card .thumb { aspect-ratio: 4 / 3; background: radial-gradient(ellipse at top, #eaf0f7, #dce4ee); display: grid; place-items: center; padding: 14px; overflow: hidden; }
.template-card .thumb img, .template-card .thumb canvas { height: 100%; width: auto; max-width: 100%; object-fit: contain; box-shadow: var(--shadow-paper); background: #fff; }
.template-card .card-body { padding: 14px 16px; }

/* ---------- Dialogi ---------- */
dialog.modal { border: 0; padding: 0; border-radius: var(--radius-l); box-shadow: 0 30px 60px -20px rgba(6, 20, 51, .5); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 40px); color: var(--ink); }
dialog.modal.wide { width: min(820px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(6, 20, 51, .55); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: rise .2s ease-out; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.modal-head { padding: 20px 24px 6px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 10px 24px 20px; }
.modal-foot { padding: 14px 24px; background: var(--paper-2); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.close-x { background: none; border: 0; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 1.3rem; line-height: 1; }
.close-x:hover { background: var(--navy-50); color: var(--navy-900); }
.secret-box { display: flex; gap: 8px; align-items: center; padding: 12px 14px; background: var(--gold-50); border: 1px dashed var(--gold); border-radius: var(--radius); font-family: var(--font-mono); font-size: 1.05rem; word-break: break-all; }

/* ---------- Toasty ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 200; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius); background: var(--navy-950); color: #fff; box-shadow: var(--shadow-2); animation: rise .2s ease-out; border-left: 4px solid var(--gold-2); font-size: .92rem; }
.toast.error { border-left-color: #f0786c; }
.toast.ok { border-left-color: #5fd19a; }

/* ---------- Logowanie ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr); }
.auth-art {
  position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: var(--guilloche) center / 240px 120px, radial-gradient(circle at 75% 35%, rgba(216, 184, 100, .22), transparent 45%), linear-gradient(140deg, var(--navy-950), var(--navy-800));
}
.auth-art img { height: 28px; width: auto; }
.auth-art blockquote { margin: 0; font-family: var(--font-display); font-size: clamp(1.5rem, 1rem + 1.6vw, 2.4rem); font-weight: 600; line-height: 1.2; max-width: 520px; }
.auth-art blockquote span { color: var(--gold-2); }
.auth-art .paper-stack { position: absolute; right: -60px; bottom: -40px; width: 300px; aspect-ratio: 210 / 297; transform: rotate(-8deg); background: #fff; border-radius: 4px; box-shadow: var(--shadow-paper); opacity: .14; }
.auth-art .paper-stack::after { content: ""; position: absolute; inset: 0; transform: rotate(6deg) translate(-30px, -20px); background: #fff; border-radius: 4px; opacity: .6; }
.auth-art footer { font-size: .8rem; color: rgba(255,255,255,.55); }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; background: var(--paper); }
.auth-form { width: min(380px, 100%); }
.auth-form h1 { margin-bottom: 6px; }
@media (max-width: 860px) { .auth-page { grid-template-columns: 1fr; } .auth-art { display: none; } }

/* ---------- Strony proste (instalator, błąd) ---------- */
.simple-page { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px; background: var(--guilloche-light) center / 320px 160px, var(--canvas); }
.simple-card { width: min(640px, 100%); background: var(--paper); border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: var(--radius-l); padding: 34px; box-shadow: var(--shadow-2); }
.simple-logo { height: 22px; width: auto; margin-bottom: 22px; }
.checklist { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 4px; font-size: .9rem; }
.checklist li.ok span:first-child { color: var(--ok); font-weight: 700; }
.checklist li.fail span:first-child { color: var(--err); font-weight: 700; }

/* ---------- Drobne ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.number-chip { font-family: var(--font-mono); font-weight: 600; background: var(--navy-50); border: 1px solid var(--navy-100); color: var(--navy-900); padding: 3px 9px; border-radius: 6px; font-size: .9rem; white-space: nowrap; }
.number-range { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.number-range .arrow { color: var(--gold); font-weight: 700; }
.token-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.token-bar button { font-family: var(--font-mono); font-size: .82rem; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--navy-100); background: var(--navy-50); color: var(--navy-800); cursor: pointer; }
.token-bar button:hover { background: var(--navy-100); }
.print-tips { counter-reset: tip; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.print-tips li { counter-increment: tip; display: grid; grid-template-columns: 30px 1fr; gap: 10px; font-size: .92rem; }
.print-tips li::before { content: counter(tip); width: 26px; height: 26px; border-radius: 50%; background: var(--gold-50); border: 1px solid #ecd9a6; color: #7a5b13; display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.fade-in { animation: fadeIn .35s ease-out both; }
.fade-in:nth-child(2) { animation-delay: .05s; }
.fade-in:nth-child(3) { animation-delay: .1s; }
.fade-in:nth-child(4) { animation-delay: .15s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
  .app-header, .toasts, .skip-link { display: none !important; }
}
