/* ============================================
   KALKULATOR ODSETEK - design "precyzyjny instrument"
   ============================================ */

:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", "Segoe UI Mono", "Roboto Mono", Menlo, Consolas, monospace;

  --bg: #EBEEF3;
  --surface: #FFFFFF;
  --surface-2: #F5F7FA;
  --ink: #0E1726;
  --ink-soft: #33415A;
  --muted: #64748B;
  --faint: #97A3B4;
  --line: #E4E8EF;
  --line-strong: #D2D9E3;
  --accent: #4F46E5;
  --accent-strong: #4338CA;
  --accent-soft: rgba(79, 70, 229, .10);
  --positive: #0E9F6E;
  --positive-soft: rgba(14, 159, 110, .10);
  --warn-ink: #92610B;
  --warn-soft: rgba(202, 138, 4, .12);
  --warn-line: rgba(202, 138, 4, .28);
  --error: #DC2626;
  --error-soft: rgba(220, 38, 38, .10);
  --error-line: rgba(220, 38, 38, .28);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 28px -12px rgba(15, 23, 42, .18);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #080D18; --surface: #10182A; --surface-2: #0C1322;
    --ink: #E7ECF5; --ink-soft: #C2CBDB; --muted: #8D9AB0; --faint: #5A6779;
    --line: #1E2838; --line-strong: #2C3849;
    --accent: #8481FF; --accent-strong: #9D9BFF; --accent-soft: rgba(132, 129, 255, .16);
    --positive: #34D399; --positive-soft: rgba(52, 211, 153, .13);
    --warn-ink: #FBBF24; --warn-soft: rgba(251, 191, 36, .12); --warn-line: rgba(251, 191, 36, .30);
    --error: #F87171; --error-soft: rgba(248, 113, 113, .12); --error-line: rgba(248, 113, 113, .30);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 18px 40px -16px rgba(0,0,0,.6);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow-lg: 0 30px 70px -20px rgba(0,0,0,.75);
  }
}
:root[data-theme="light"] {
  --bg: #EBEEF3; --surface: #FFFFFF; --surface-2: #F5F7FA;
  --ink: #0E1726; --ink-soft: #33415A; --muted: #64748B; --faint: #97A3B4;
  --line: #E4E8EF; --line-strong: #D2D9E3;
  --accent: #4F46E5; --accent-strong: #4338CA; --accent-soft: rgba(79,70,229,.10);
  --positive: #0E9F6E; --positive-soft: rgba(14,159,110,.10);
  --warn-ink: #92610B; --warn-soft: rgba(202,138,4,.12); --warn-line: rgba(202,138,4,.28);
  --error: #DC2626; --error-soft: rgba(220,38,38,.10); --error-line: rgba(220,38,38,.28);
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 12px 28px -12px rgba(15,23,42,.18);
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
  --shadow-lg: 0 24px 60px -20px rgba(15,23,42,.35);
}
:root[data-theme="dark"] {
  --bg: #080D18; --surface: #10182A; --surface-2: #0C1322;
  --ink: #E7ECF5; --ink-soft: #C2CBDB; --muted: #8D9AB0; --faint: #5A6779;
  --line: #1E2838; --line-strong: #2C3849;
  --accent: #8481FF; --accent-strong: #9D9BFF; --accent-soft: rgba(132,129,255,.16);
  --positive: #34D399; --positive-soft: rgba(52,211,153,.13);
  --warn-ink: #FBBF24; --warn-soft: rgba(251,191,36,.12); --warn-line: rgba(251,191,36,.30);
  --error: #F87171; --error-soft: rgba(248,113,113,.12); --error-line: rgba(248,113,113,.30);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 18px 40px -16px rgba(0,0,0,.6);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-lg: 0 30px 70px -20px rgba(0,0,0,.75);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-sans); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
a { color: var(--accent); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem clamp(1rem, 4vw, 2rem);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 640; letter-spacing: -.01em; text-decoration: none; color: var(--ink); }
.brand .glyph {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(155deg, var(--accent), var(--accent-strong));
  color: #fff; font-family: var(--font-mono); font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 12px -3px var(--accent-soft);
}
.brand b { font-weight: 660; }
.brand span { color: var(--muted); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: .5rem; }
.status {
  display: inline-flex; align-items: center; gap: .45rem; font-size: 12.5px; color: var(--muted);
  padding: .35rem .65rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--positive); box-shadow: 0 0 0 3px var(--positive-soft); }
.buffer-btn {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600;
  padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-soft);
  transition: .16s ease;
}
.buffer-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.buffer-btn strong { color: var(--accent); font-family: var(--font-mono); }
.buffer-btn.buffer-added { animation: pulse .5s ease; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center; cursor: pointer;
  background: var(--surface); color: var(--ink-soft); border: 1px solid var(--line); transition: .18s ease;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .moon { display: none; }
:root[data-theme="dark"] .icon-btn .sun { display: none; }
:root[data-theme="dark"] .icon-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn .sun { display: none; }
  :root:not([data-theme="light"]) .icon-btn .moon { display: block; }
}

/* ---------- Layout ---------- */
.container { max-width: 760px; margin: 0 auto; padding: clamp(1.4rem, 4vw, 2.6rem) clamp(1rem, 4vw, 2rem) 1rem; }
.lede { margin: 0 0 1.6rem; }
.lede h1 { margin: 0 0 .5rem; font-size: clamp(1.5rem, 4.5vw, 2.05rem); font-weight: 680; letter-spacing: -.025em; line-height: 1.13; text-wrap: balance; }
.lede p { margin: 0; color: var(--muted); }
.lede .basis { color: var(--ink-soft); font-weight: 550; }
.disclaimer-top {
  margin-top: .85rem; font-size: 13px; color: var(--ink-soft);
  padding: .6rem .8rem; background: var(--warn-soft); border: 1px solid var(--warn-line);
  border-radius: var(--radius-xs); display: flex; gap: .55rem; align-items: center; line-height: 1.45;
}
.disclaimer-top svg { width: 16px; height: 16px; color: var(--warn-ink); flex: none; }

main { display: flex; flex-direction: column; gap: 1.4rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: clamp(1.2rem, 3.5vw, 1.75rem); }

/* ---------- Form ---------- */
form { display: flex; flex-direction: column; gap: 1.15rem; }
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group > label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.form-group small { font-size: 12px; color: var(--faint); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row .form-group { margin: 0; }

input[type="text"], input[type="date"], select {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: .7rem .85rem;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
#kwota, #stawka_umowna { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1.02rem; letter-spacing: -.01em; }
input[type="date"] { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .65; }
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .55; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .55; } }

select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 6 7 9 10 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .85rem center; padding-right: 2.4rem; }
optgroup { font-weight: 700; color: var(--muted); }
option { color: var(--ink); background: var(--surface); font-weight: 400; }

.checkbox-group { gap: .3rem; }
.checkbox-label { display: flex; align-items: flex-start; gap: .6rem; font-size: 13.5px; cursor: pointer; padding: .3rem 0; }
.checkbox-label input { margin-top: .15rem; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.help-text { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 0; }
#opcje_umowne, #opcje_cywilne, #opcje_podatkowe { gap: .6rem; }

.btn-primary {
  width: 100%; font: inherit; font-weight: 640; font-size: 1rem; cursor: pointer;
  padding: .85rem 1rem; border: 0; border-radius: var(--radius-sm); color: #fff;
  background: linear-gradient(150deg, var(--accent), var(--accent-strong));
  box-shadow: 0 8px 20px -8px var(--accent-soft), inset 0 1px 0 rgba(255,255,255,.14);
  transition: transform .12s ease, filter .16s ease; letter-spacing: -.005em;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: translateY(1px); }
:root[data-theme="dark"] .btn-primary { color: #0A0F1C; }

/* ---------- Loading ---------- */
.htmx-indicator { display: none; align-items: center; justify-content: center; gap: .6rem; padding: 1.4rem; color: var(--muted); font-size: 14px; }
.htmx-indicator.htmx-request { display: flex; }
.spinner { width: 20px; height: 20px; border: 2.5px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Wynik (partial) ---------- */
.result-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; animation: rise .28s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.result-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 1.15rem clamp(1.2rem, 3.5vw, 1.75rem); border-bottom: 1px solid var(--line); }
.result-header h2 { margin: 0; font-size: 1.05rem; font-weight: 640; letter-spacing: -.01em; }
.result-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.btn-add-buffer, .btn-export, .btn-print {
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: .35rem; padding: .48rem .75rem; border-radius: var(--radius-xs);
  background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line); transition: .16s;
}
.btn-add-buffer:hover, .btn-export:hover, .btn-print:hover { border-color: var(--line-strong); color: var(--ink); }
.btn-add-buffer { border-color: var(--positive); color: var(--positive); }
.btn-add-buffer:hover { background: var(--positive-soft); color: var(--positive); border-color: var(--positive); }

.info-box { margin: 1rem clamp(1.2rem, 3.5vw, 1.75rem) 0; padding: .8rem .95rem; font-size: 13px; line-height: 1.55;
  border-radius: var(--radius-xs); border: 1px solid var(--line); }
.info-box strong { font-weight: 660; }
.info-warning { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-ink); }
.info-neutral { background: var(--surface-2); border-color: var(--line); color: var(--ink-soft); }
.info-success { background: var(--positive-soft); border-color: color-mix(in srgb, var(--positive) 30%, transparent); color: var(--positive); }

.summary { margin: 1.2rem clamp(1.2rem, 3.5vw, 1.75rem); display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.summary-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: .7rem .95rem; border-bottom: 1px solid var(--line); }
.summary-row:last-child { border-bottom: 0; }
.summary-row .label { color: var(--muted); font-size: 13px; }
.summary-row .value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; color: var(--ink); letter-spacing: -.01em; }
.summary-row.highlight { background: var(--positive-soft); }
.summary-row.highlight .label { color: var(--ink-soft); font-weight: 600; }
.summary-row.highlight .value.big { font-size: 1.6rem; color: var(--positive); font-weight: 680; }
.summary-row.highlight-total { background: var(--accent-soft); }
.summary-row.highlight-total .label { color: var(--ink-soft); font-weight: 600; }
.summary-row.highlight-total .value.big { font-size: 1.35rem; color: var(--accent); font-weight: 680; }

.details-section { margin: 0 clamp(1.2rem, 3.5vw, 1.75rem); border-top: 1px solid var(--line); }
.details-section summary { list-style: none; cursor: pointer; padding: 1rem 0 .9rem; display: flex; align-items: center; gap: .5rem;
  font-weight: 600; font-size: 13.5px; color: var(--accent); }
.details-section summary::-webkit-details-marker { display: none; }
.details-section summary::before { content: "▸"; transition: transform .2s; display: inline-block; }
.details-section[open] summary::before { transform: rotate(90deg); }
.periods-table { width: 100%; border-collapse: collapse; font-size: 12.5px; display: block; overflow-x: auto; padding-bottom: 1.2rem; }
.periods-table thead, .periods-table tbody, .periods-table tfoot { display: table; width: 100%; min-width: 520px; }
.periods-table th { text-align: left; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700;
  padding: .5rem .6rem; border-bottom: 1px solid var(--line-strong); }
.periods-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.periods-table td:first-child, .periods-table td:nth-child(2) { color: var(--ink-soft); }
.periods-table .center { text-align: center; }
.periods-table .right { text-align: right; }
.periods-table td.center:nth-child(4) { color: var(--accent); font-weight: 600; }
.periods-table .small { font-family: var(--font-mono); font-size: 11px; color: var(--faint); }
.periods-table tfoot td { border-top: 2px solid var(--line-strong); border-bottom: 0; font-weight: 700; }

.formula { margin: 0 clamp(1.2rem, 3.5vw, 1.75rem) 1.4rem; padding: .8rem .95rem; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-xs); font-size: 12.5px; color: var(--muted); }
.formula strong { color: var(--ink-soft); }
.formula small { color: var(--faint); }

.error-card { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.25rem; margin-top: 0;
  background: var(--error-soft); border: 1px solid var(--error-line); border-radius: var(--radius); color: var(--error); animation: shake .4s ease; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }
.error-icon { font-size: 1.35rem; }
.error-message { margin: 0; font-weight: 550; }

/* ---------- Batch ---------- */
.batch-section h2 { margin: 0 0 .35rem; font-size: 1.1rem; font-weight: 640; letter-spacing: -.01em; display: flex; align-items: center; gap: .55rem; }
.batch-section h2::before { content: "Excel"; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); padding: .2rem .5rem; border-radius: 6px; }
.batch-section > .help-text { margin-bottom: 1.1rem; }
.batch-drop { border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2);
  padding: 1.5rem 1.25rem; text-align: center; transition: .18s; }
.batch-drop.batch-drop-over { border-color: var(--accent); background: var(--accent-soft); }
#batchFile { display: none; }
.batch-drop-text { margin: 0 0 .9rem; color: var(--muted); font-size: 13.5px; }
.batch-controls { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: center; }
.batch-controls .btn-primary { width: auto; padding: .6rem 1rem; font-size: .9rem; }
.batch-status { font-size: 13px; min-height: 1.2rem; margin-top: .7rem; }
.batch-status.batch-loading { color: var(--accent); }
.batch-status.batch-ok { color: var(--positive); font-weight: 500; }
.batch-status.batch-error { color: var(--error); font-weight: 500; }
.batch-legend { margin-top: 1rem; border-top: 1px solid var(--line); }
.batch-legend summary { list-style: none; cursor: pointer; padding: .7rem 0; font-size: 13px; font-weight: 600; color: var(--accent); display: flex; align-items: center; gap: .5rem; }
.batch-legend summary::-webkit-details-marker { display: none; }
.batch-legend summary::before { content: "▸"; transition: transform .2s; display: inline-block; }
.batch-legend[open] summary::before { transform: rotate(90deg); }
.batch-legend ul { margin: .3rem 0 .6rem; padding-left: 1.15rem; font-size: 13px; color: var(--ink-soft); line-height: 1.7; }
.batch-legend ul strong { color: var(--ink); }

/* Uniwersalne przyciski wtórne */
.btn-secondary { font: inherit; font-size: .875rem; font-weight: 550; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: .4rem; padding: .58rem .95rem; border-radius: var(--radius-xs);
  background: var(--surface); color: var(--ink-soft); border: 1px solid var(--line-strong); transition: .16s; }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger-small { font: inherit; font-size: 12px; font-weight: 550; cursor: pointer;
  padding: .5rem .75rem; border-radius: var(--radius-xs); background: transparent; color: var(--error); border: 1px solid currentColor; transition: .16s; }
.btn-danger-small:hover { background: var(--error); color: #fff; }

/* ---------- Bufor (modal) ---------- */
.modal { display: none; position: fixed; inset: 0; z-index: 60; background: rgba(6,10,20,.55); backdrop-filter: blur(3px);
  align-items: flex-start; justify-content: center; padding: clamp(1rem, 5vh, 3rem) 1rem; overflow-y: auto; }
.modal.show { display: flex; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-content { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); max-width: 860px; width: 100%; box-shadow: var(--shadow-lg); }
.modal-header { position: sticky; top: 0; background: var(--surface); display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.modal-header h2 { margin: 0; font-size: 1.1rem; font-weight: 660; }
.modal-header-actions { display: flex; align-items: center; gap: .5rem; }
.modal-close { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.modal-close:hover { color: var(--ink); border-color: var(--line-strong); }
.modal-body { padding: 1.4rem; overflow-x: auto; }

.buffer-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
.buffer-table th { text-align: left; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700;
  padding: .55rem .6rem; border-bottom: 1px solid var(--line-strong); }
.buffer-table td { padding: .6rem .6rem; border-bottom: 1px solid var(--line); }
.buffer-table .right { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.buffer-table .center { text-align: center; font-family: var(--font-mono); }
.buffer-total td { background: var(--surface-2); font-weight: 700; border-top: 2px solid var(--line-strong); }
.buffer-grand-total td { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.btn-remove { background: none; border: 0; color: var(--faint); font-size: 1.15rem; line-height: 1; cursor: pointer; padding: .1rem .4rem; }
.btn-remove:hover { color: var(--error); }
.buffer-empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

/* ---------- Stopka ---------- */
footer { max-width: 760px; margin: 0 auto; padding: 1.4rem clamp(1rem, 4vw, 2rem) 3rem; color: var(--muted); font-size: 12.5px; }
footer .disc { padding: 1rem 1.15rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); line-height: 1.55; }
footer .disc strong { color: var(--ink-soft); }
footer .legal { margin-top: .9rem; line-height: 1.6; color: var(--faint); }
.foot-links { margin-top: 1.1rem; display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.foot-links a { color: var(--ink-soft); text-decoration: none; font-weight: 550; border-bottom: 1px solid transparent; cursor: pointer; }
.foot-links a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.foot-links span { color: var(--faint); }

/* ---------- Baner cookies ---------- */
.cookie-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; padding: .9rem clamp(1rem, 4vw, 2rem);
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); box-shadow: 0 -8px 30px -18px rgba(0,0,0,.4); }
.cookie-inner { max-width: 960px; margin: 0 auto; display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.cookie-inner p { margin: 0; font-size: 13px; color: var(--ink-soft); max-width: 62ch; line-height: 1.5; }
.cookie-inner a { color: var(--accent); text-decoration: none; font-weight: 600; cursor: pointer; }
.cookie-actions { display: flex; gap: .5rem; flex: none; }
.btn-cookie-primary { font: inherit; font-size: 13px; font-weight: 620; cursor: pointer; padding: .55rem .9rem; border-radius: var(--radius-xs);
  border: 1px solid var(--accent); background: var(--accent); color: #fff; transition: .16s; }
.btn-cookie-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
:root[data-theme="dark"] .btn-cookie-primary { color: #0A0F1C; }

/* ---------- Dokumenty (Regulamin / Polityka) ---------- */
.doc-modal { display: none; position: fixed; inset: 0; z-index: 70; background: rgba(6,10,20,.55); backdrop-filter: blur(3px);
  align-items: flex-start; justify-content: center; padding: clamp(1rem, 5vh, 3rem) 1rem; overflow-y: auto; }
.doc-modal.show { display: flex; }
.doc-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); max-width: 720px; width: 100%;
  box-shadow: var(--shadow-lg); animation: rise .22s ease; }
.doc-top { position: sticky; top: 0; z-index: 1; background: var(--surface); display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.doc-top h2 { margin: 0; font-size: 1.15rem; font-weight: 660; letter-spacing: -.01em; }
.doc-body { padding: 1.4rem; font-size: 14px; line-height: 1.65; color: var(--ink-soft); }
.doc-body h3 { margin: 1.6rem 0 .5rem; font-size: .98rem; font-weight: 660; color: var(--ink); }
.doc-body h3:first-child { margin-top: 0; }
.doc-body h4 { margin: 1.1rem 0 .2rem; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.doc-body p { margin: 0 0 .7rem; }
.doc-body ul { margin: 0 0 .8rem; padding-left: 1.15rem; }
.doc-body li { margin-bottom: .35rem; }
.doc-body strong { color: var(--ink); }
.doc-body .callout { padding: .85rem .95rem; background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: var(--radius-xs);
  color: var(--warn-ink); font-size: 13.5px; margin: 0 0 1.1rem; line-height: 1.55; }
.doc-body .updated { font-size: 12px; color: var(--faint); margin-top: 1.6rem; padding-top: .9rem; border-top: 1px solid var(--line); }

.rates-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: .4rem 0 1.1rem; }
.rates-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700;
  padding: .45rem .6rem; border-bottom: 1px solid var(--line-strong); }
.rates-table td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); }
.rates-table tr:last-child td { border-bottom: 0; }
.rates-table td.num { text-align: right; }
.rates-table .rate { color: var(--accent); font-weight: 600; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.rates-table .date { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.rates-table .src { font-family: var(--font-mono); color: var(--faint); font-size: 11.5px; }
.rates-table .lbl { color: var(--ink); }
.hist { margin: .2rem 0 1rem; border: 1px solid var(--line); border-radius: var(--radius-xs); }
.hist > summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--accent); padding: .7rem .9rem; list-style: none; display: flex; gap: .5rem; align-items: center; }
.hist > summary::-webkit-details-marker { display: none; }
.hist > summary::before { content: "▸"; transition: transform .2s; display: inline-block; }
.hist[open] > summary::before { transform: rotate(90deg); }
.hist-inner { padding: 0 .9rem 1rem; overflow-x: auto; }

/* ---------- Responsywność ---------- */
@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
  .status { display: none; }
  .summary-row.highlight .value.big { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Druk ---------- */
@media print {
  body { background: #fff !important; color: #000; }
  .topbar, footer, form, #loading, .batch-section, .cookie-bar, .doc-modal, .modal, .result-actions, .disclaimer-top, .lede p { display: none !important; }
  .container { max-width: 100%; padding: 0; }
  .card, .result-card { box-shadow: none !important; border: none !important; }
  .result-header { border-bottom: 2px solid #000; }
  .summary, .info-box, .periods-table thead, .periods-table tbody, .periods-table tfoot { display: table; width: 100%; }
  .summary { border: 1px solid #ccc; }
  .summary-row.highlight .value.big, .summary-row.highlight-total .value.big { color: #000 !important; }
  .periods-table th, .periods-table td { border: 1px solid #ccc !important; }
  details[open] summary::before, .details-section summary::before { content: ""; }
  .details-section summary { display: none; }
  @page { margin: 1.5cm; size: A4; }
}
