.jdg-calc { --jdg-gap: 16px; }
.status-banner {
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: .88rem;
  margin-bottom: var(--jdg-gap);
}
.status-banner[data-level="ok"] {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}
.jdg-calc__grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(0, 1.55fr);
  gap: var(--jdg-gap);
}
@media (max-width: 900px) {
  .jdg-calc__grid { grid-template-columns: 1fr; }
}
.jdg-panel {
  background: #f8fafc;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 14px;
  padding: 18px;
}
.jdg-panel h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.field { margin-bottom: 16px; }
.field label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  font-size: .88rem;
  margin-bottom: 6px;
}
.hint { font-weight: 500; font-size: .72rem; color: #64748b; }
.num-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.jdg-panel input[type="number"],
.jdg-panel select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
  font-size: 1rem;
}
.jdg-panel input[type="range"] { width: 100%; margin-top: 8px; accent-color: #2563eb; }
.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: .88rem;
  font-weight: 500;
  margin: 8px 0;
}
.assumptions {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  font-size: .8rem;
  color: #64748b;
}
.assumptions summary {
  cursor: pointer;
  font-weight: 700;
  color: #0f172a;
}
.assumptions ul { margin: 8px 0 0; padding-left: 1.1rem; }
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 700px) {
  .cards { grid-template-columns: 1fr; }
}
.card {
  position: relative;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
}
.card.winner {
  border-color: #059669;
  background: #ecfdf5;
  box-shadow: 0 12px 28px rgba(5,150,105,.12);
}
.badge {
  display: none;
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #059669;
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.card.winner .badge { display: inline-block; }
.card h3 {
  margin: 8px 0 8px;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #64748b;
}
.net { font-size: 1.45rem; font-weight: 800; letter-spacing: -.03em; margin: 0; }
.net-sub {
  font-size: .68rem;
  font-weight: 700;
  color: #059669;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 2px 0 10px;
}
.tier {
  display: none;
  font-size: .7rem;
  font-weight: 600;
  background: #e0f2fe;
  color: #0369a1;
  padding: 4px 10px;
  border-radius: 999px;
  margin: 0 auto 10px;
  width: fit-content;
}
.tier.show { display: inline-block; }
.rows {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
  text-align: left;
  font-size: .8rem;
  color: #64748b;
  line-height: 1.7;
}
.row { display: flex; justify-content: space-between; gap: 8px; }
.total {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #cbd5e1;
  color: #dc2626;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
}
.diff { margin-top: 8px; font-size: .75rem; font-weight: 600; color: #64748b; min-height: 1.2em; }
.card.winner .diff { color: #059669; }
.chart-box {
  margin-top: 14px;
  height: 300px;
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px;
}
.alert {
  padding: 12px 14px;
  border-radius: 12px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
  font-size: .86rem;
  margin-bottom: 12px;
}


/* Mobile card safety */
@media (max-width: 700px) {
  .cards {
    grid-template-columns: 1fr;
    width: 100%;
  }
  .card {
    width: 100%;
    max-width: 100%;
  }
  .jdg-calc__grid {
    grid-template-columns: 1fr;
  }
}

/* card rows one line */
.row,
.total {
  flex-wrap: nowrap;
}
.row span:last-child,
.total span:last-child {
  white-space: nowrap;
  flex-shrink: 0;
}
.net-sub { white-space: nowrap; }

.jdg-zus-hint { margin: 6px 0 0; font-size: .75rem; color: #64748b; }

/* ZUS społeczny breakdown (1.6.5) */
.zus-bd > summary { list-style: none; cursor: pointer; }
.zus-bd > summary::-webkit-details-marker { display: none; }
.zus-bd__label::after {
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  margin-left: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .15s ease;
}
.zus-bd[open] .zus-bd__label::after { transform: translateY(0) rotate(-135deg); }
.zus-bd > summary:hover .zus-bd__label,
.zus-bd > summary:focus-visible .zus-bd__label { color: #0f172a; text-decoration: underline dotted; }
.zus-bd__body {
  margin: 2px 0 4px 6px;
  padding-left: 8px;
  border-left: 2px solid #e2e8f0;
  font-size: .72rem;
  line-height: 1.55;
  color: #94a3b8;
}
.zus-bd__row { display: flex; justify-content: space-between; gap: 8px; }
.zus-bd__row span:last-child { white-space: nowrap; color: #64748b; }
.zus-bd__hint, .zus-bd__note { margin: 3px 0 0; font-size: .68rem; line-height: 1.4; color: #94a3b8; }
.card.winner .zus-bd__body { border-left-color: #a7f3d0; }

/* Start date / schedule (1.6.5) */
.jdg-panel input[type="date"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
  font-size: 1rem;
  background: #fff;
  min-height: 44px;
}
.jdg-start-elig { margin-top: 8px; }
.field .jdg-start-elig label.check {
  justify-content: flex-start;
  font-weight: 500;
  font-size: .82rem;
  margin: 4px 0;
}
.jdg-sched {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f0f9ff;
  color: #0c4a6e;
  font-size: .74rem;
  line-height: 1.45;
}
.jdg-sched[hidden], .jdg-start-elig[hidden] { display: none; }

/* 1.6.8: more room for descriptive ryczałt rate labels on small phones */
@media (max-width: 420px) {
  .jdg-panel { padding: 14px 12px; }
  .jdg-panel select { padding-left: 10px; padding-right: 10px; }
}

/* ===== 1.7.0: presets, period toggle, gain badge, deductions, crossovers, tooltips, sticky bar ===== */
.field__label-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.field__label-row label { margin: 0; }
.field__label-row .hint { margin-left: auto; }
.jdg-range { height: 28px; }
.jdg-eq { margin: 2px 0 0; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.chips__label { flex-basis: 100%; font-size: .72rem; font-weight: 600; color: #64748b; }
.chip {
  appearance: none; font: inherit; font-size: .8rem; font-weight: 600; color: #1e3a8a;
  background: #fff; border: 1px solid #cbd5e1; border-radius: 999px; padding: 6px 11px; min-height: 34px;
  cursor: pointer; white-space: nowrap; line-height: 1.2;
}
.chip:hover { border-color: #2563eb; }
.chip.is-active { background: #2563eb; border-color: #2563eb; color: #fff; }
.chip:focus-visible, .seg__btn:focus-visible, .tip__btn:focus-visible, .jdg-sticky__step:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

.seg { display: flex; width: fit-content; margin: 0 0 12px auto; background: #f1f5f9; border-radius: 999px; padding: 4px; gap: 4px; }
.seg__btn {
  appearance: none; border: 0; background: transparent; font: inherit; font-size: .82rem; font-weight: 700; color: #64748b;
  padding: 7px 14px; border-radius: 999px; cursor: pointer; min-height: 34px;
}
.seg__btn.is-active { background: #fff; color: #1e40af; box-shadow: 0 1px 3px rgba(15,23,42,.1); }
@media (max-width: 900px) { .seg { margin: 4px auto 12px; } }

.gain {
  margin: 0 auto 10px; width: fit-content; max-width: 100%; padding: 4px 10px; border-radius: 999px;
  background: #d1fae5; color: #065f46; font-size: .74rem; font-weight: 700; line-height: 1.35;
}
.gain[hidden] { display: none; }
.card.winner { box-shadow: 0 8px 22px rgba(5,150,105,.12); }

.row--ded { color: #94a3b8; font-size: .74rem; }
.row--danina[hidden] { display: none; }
.rows .row > span:first-child { min-width: 0; }

/* tooltips */
.tip { position: relative; display: inline-flex; vertical-align: middle; }
.tip__btn {
  appearance: none; border: 0; background: none; padding: 0; margin: 0; font: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; color: #1d4ed8; line-height: 1;
  min-width: 24px; min-height: 24px; justify-content: center;
}
.tip__q {
  display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  background: #e0e7ff; color: #1e40af; font-size: .66rem; font-weight: 800;
}
.tip.is-open .tip__q { background: #1d4ed8; color: #fff; }
.tip--term .tip__btn { font-size: .78rem; font-weight: 600; text-decoration: underline dotted; text-underline-offset: 3px; min-width: 0; }
.tip__pop {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 50%;
  transform: translateX(calc(-50% + var(--tip-shift, 0px)));
  width: max-content; max-width: min(280px, calc(100vw - 24px));
  background: #0f172a; color: #f8fafc; font-size: .76rem; font-weight: 500; line-height: 1.45; text-align: left;
  text-transform: none; letter-spacing: 0; white-space: normal;
  padding: 10px 12px; border-radius: 10px; box-shadow: 0 10px 24px rgba(15,23,42,.25);
}
.tip__pop[hidden] { display: none; }
.tip-terms { margin: 6px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; font-size: .74rem; color: #64748b; }

/* profit vs revenue chart */
.chart-box--cross { height: auto; padding: 14px 12px 10px; }
.chart-box__title { margin: 0 0 2px; font-size: .9rem; color: #0f172a; }
.chart-box__sub { margin: 0 0 8px; font-size: .74rem; color: #64748b; line-height: 1.45; }
.chart-box__canvas { position: relative; height: 300px; }
.cross-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: .78rem; color: #334155; line-height: 1.5; }
.cross-list li { display: flex; gap: 8px; align-items: baseline; }
.cross-dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; border: 2.5px solid var(--c); background: #fff; transform: translateY(1px); }
.cross-list__note { color: #94a3b8; font-size: .72rem; }
@media (max-width: 480px) { .chart-box__canvas { height: 280px; } .chart-box { height: 280px; } .chart-box--cross { height: auto; } }

/* sticky revenue bar (mobile only) */
.jdg-sticky {
  position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; grid-template-areas: "m f p" "b b b";
  align-items: center; gap: 4px 8px; padding: 8px 10px; max-width: 560px; margin: 0 auto;
  background: rgba(255,255,255,.97); border: 1px solid #cbd5e1; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15,23,42,.18);
}
.jdg-sticky[hidden] { display: none; }
.jdg-sticky__step {
  appearance: none; width: 40px; height: 40px; border-radius: 10px; border: 1px solid #cbd5e1; background: #f8fafc;
  font: inherit; font-size: 1.25rem; font-weight: 700; color: #1e40af; cursor: pointer;
}
.jdg-sticky__step[data-sticky-step="-1"] { grid-area: m; }
.jdg-sticky__step[data-sticky-step="1"] { grid-area: p; }
.jdg-sticky__field { grid-area: f; display: grid; gap: 1px; font-size: .66rem; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .03em; }
.jdg-sticky__field input {
  width: 100%; min-width: 0; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 8px;
  font: inherit; font-size: 1rem; font-weight: 700; color: #0f172a; text-transform: none; letter-spacing: 0;
}
.jdg-sticky__best { grid-area: b; font-size: .74rem; font-weight: 700; color: #065f46; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.has-jdg-sticky { padding-bottom: 104px; }
@media (min-width: 901px) { .jdg-sticky { display: none !important; } body.has-jdg-sticky { padding-bottom: 0; } }
/* card-row labels may wrap and must not clip tooltips (main.css sets overflow:hidden + ellipsis on .row spans) */
.jdg-calc .rows .row > span:first-child { overflow: visible; white-space: normal; text-overflow: clip; }
.jdg-calc .row .tip, .jdg-calc .row .tip span { overflow: visible; text-overflow: clip; min-width: 0; flex-shrink: 1; }
.jdg-calc .row .tip__pop { white-space: normal; color: #f8fafc; text-align: left; font-weight: 500; }
.jdg-calc .row .tip__q { color: #1e40af; white-space: nowrap; }
.jdg-calc .row .tip.is-open .tip__q { color: #fff; }
/* preset chips: 4 per row (2 on very small phones) */
.chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.chips__label { grid-column: 1 / -1; }
.chip { padding: 6px 4px; font-size: .76rem; text-align: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* 1.7.2: JS switches a group to 2 columns when any label would be cut (language/font dependent) */
.chips.chips--2col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 340px) { .chips { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 1.8.2: wakacje składkowe (PL only) */
.jdg-wak { padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 12px; background: #f8fafc; }
.field.jdg-wak > label.check { justify-content: flex-start; margin: 0; font-size: .88rem; font-weight: 600; color: #0f172a; }
.field.jdg-wak > label.check input { width: auto; margin-top: 2px; }
.jdg-wak__month { margin-top: 8px; }
.jdg-wak__month[hidden], .jdg-wak__status[hidden], .zus-bd__wak[hidden] { display: none; }
.jdg-wak__month label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 4px; }
.jdg-wak__hint { margin: 6px 0 0; font-size: .74rem; line-height: 1.45; color: #64748b; }
.jdg-wak__status { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; background: #ecfdf5; color: #065f46; font-size: .76rem; line-height: 1.45; }
.jdg-wak__status[data-level="zero"] { background: #fffbeb; color: #92400e; }
.jdg-wak__who { margin-top: 8px; font-size: .76rem; color: #475569; }
.jdg-wak__who summary { cursor: pointer; font-weight: 600; color: #1d4ed8; }
.jdg-wak__who ul { margin: 6px 0 0; padding-left: 1.1rem; line-height: 1.45; }
.jdg-wak__who li { margin: 2px 0; }
.jdg-wak__disclaimer { margin: 6px 0 0; font-size: .72rem; color: #64748b; }
.zus-bd__wak { margin: 2px 0 4px; font-size: .7rem; line-height: 1.35; color: #047857; text-align: right; }

/* 1.8.21: Mały ZUS Plus field + revenue threshold bar */
.jdg-maly { margin-top: 10px; }
.jdg-maly[hidden] { display: none; }
.jdg-maly__note { margin: 6px 0 0; font-size: .74rem; line-height: 1.45; }
.jdg-thr { margin-top: 12px; }
.jdg-thr__title { margin: 0 0 6px; font-size: .8rem; font-weight: 600; color: #0f172a; }
.jdg-thr__track { position: relative; height: 12px; border-radius: 6px; background: #e2e8f0; margin: 0 0 22px; }
.jdg-thr__fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 6px; background: #3b82f6; transition: width .2s; }
.jdg-thr__mark { position: absolute; top: -3px; width: 2px; height: 18px; background: #64748b; transform: translateX(-1px); }
.jdg-thr__mark.is-over { background: #b91c1c; }
.jdg-thr__mlabel { position: absolute; top: 19px; left: 50%; transform: translateX(-50%); font-size: .66rem; color: #475569; white-space: nowrap; }
.jdg-thr__list { list-style: none; margin: 0; padding: 0; font-size: .74rem; line-height: 1.45; }
.jdg-thr__list li { margin: 3px 0; padding-left: 14px; position: relative; }
.jdg-thr__list li::before { content: ''; position: absolute; left: 0; top: .45em; width: 8px; height: 8px; border-radius: 50%; background: #16a34a; }
.jdg-thr__list li.is-over::before { background: #b91c1c; }
.jdg-thr__list li.is-info::before { background: #94a3b8; }
.jdg-thr__st { font-weight: 600; white-space: nowrap; }
.jdg-thr__disc { margin: 6px 0 0; font-size: .7rem; line-height: 1.45; color: #64748b; }
@media (max-width: 600px) { .jdg-thr__mlabel { display: none; } .jdg-thr__track { margin-bottom: 10px; } }
