:root{
  --ink:#0f172a; --muted:#64748b;
  --c1:#a5b4fc; --c2:#93c5fd; --c3:#86efac; --c4:#fbcfe8; --c5:#a7f3d0;
  --bg:#f7fbff;
  --ui-scale:1;           /* global scale */
  --portrait-scale:.98;   /* 0.96–1.00 w zależności od telefonu */

  /* === ZMIENNE: TABELA WYNIKÓW === */
  --tnw-table-font: Poppins, Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --tnw-table-line: 1.3;
  --tnw-th-size: 13px;        /* nagłówki (desktop) */
  --tnw-td-size: 13px;        /* komórki (desktop) */
  --tnw-th-weight: 600;
  --tnw-td-weight: 400;
  --tnw-th-size-sm: 12.5px;   /* mobile */
  --tnw-td-size-sm: 12.5px;

  /* === ZMIENNE: GRID KALKULATORA (wariant 2) === */
  --mod-head-size: 16px;      /* tytuły sekcji */
  --mod-item-size: 15px;      /* etykiety opcji */
  --mod-item-size-sm: 13px;   /* etykiety na mobile */
}

*,
*::before,
*::after{ box-sizing:border-box }

html{ -webkit-text-size-adjust:100% }

/* === SHELL (full-bleed) === */
#tnw-doradca-prosty.tnw-shell{
  position:relative;
  font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  color:var(--ink);
  overflow-x:clip;                  /* iOS – nic się nie ucina po prawej */
  width:100vw;                         /* pełna szerokość okna */
  margin-left:calc(50% - 50vw);        /* wyjście z kontenera motywu */
  margin-right:calc(50% - 50vw);
}

/* --- TŁO / PARALLAX (skalowalne do 4K) --- */
#tnw-doradca-prosty .tnw-bg{
  position:fixed; inset:0; z-index:-2;
  background:
    radial-gradient(900px 600px at 80% -10%, rgba(165,180,252,.22), transparent 60%),
    radial-gradient(800px 600px at -10% 10%, rgba(147,197,253,.22), transparent 60%),
    radial-gradient(700px 500px at 90% 70%, rgba(167,243,208,.20), transparent 60%),
    #f7fbff;
}
.parallax-blob{position:absolute;border-radius:50%;filter:blur(34px);opacity:.55;pointer-events:none;z-index:-1}
#p1{
  width:clamp(520px,28vw,1200px); height:clamp(520px,28vw,1200px);
  background:radial-gradient(circle at 40% 30%,var(--c2),var(--c1));
  top:-10vh; left:-4vw;                 /* było -8vw → bezpieczniej względem body overflow */
  animation:float 7s ease-in-out infinite alternate;
}
#p2{
  width:clamp(420px,24vw,1000px); height:clamp(420px,24vw,1000px);
  background:radial-gradient(circle at 60% 50%,var(--c4),var(--c2));
  top:44vh; right:-4vw;                 /* było -10vw */
  animation:float 10s ease-in-out infinite alternate-reverse;
}
#p3{
  width:clamp(360px,22vw,900px); height:clamp(360px,22vw,900px);
  background:radial-gradient(circle at 50% 40%,var(--c3),var(--c5));
  top:70vh; left:-4vw;                  /* było -8vw */
  animation:float 9s ease-in-out infinite alternate;
}
@keyframes float{from{transform:translateY(0)}to{transform:translateY(-14px)}}

/* --- LAYOUT (desktop/landscape) --- */
.tnw-container{
  max-width:1200px;                              /* szerzej na PC */
  width:min(1200px, 98vw);                       /* było 96vw → wypełnia więcej */
  margin:0 auto;
  padding-inline:clamp(12px,2vw,20px);           /* responsywne boczne odstępy */
}
.tnw-header{padding:56px 0 26px}
.tnw-title{
  font-family:Poppins,Arial,sans-serif;
  font-weight:900; letter-spacing:.3px; margin:0;
  font-size:clamp(28px,4vw,48px);
  color:#0b2039; text-shadow:0 2px 0 rgba(255,255,255,.5);
}
.glass{background:rgba(255,255,255,.65);backdrop-filter:blur(16px);border:1px solid rgba(255,255,255,.7)}
.tnw-banner{margin-top:16px;border-radius:22px;overflow:hidden;box-shadow:0 10px 25px rgba(0,0,0,.08), inset 0 1px 0 rgba(255,255,255,.35)}
.tnw-banner-bar{height:10px;background:linear-gradient(90deg,var(--c2),var(--c4),var(--c3))}
.tnw-banner-text{padding:14px 22px;font-size:16px;color:#42526b}
.tnw-main{padding:8px 0 28px}
.tnw-card{border-radius:22px;padding:22px;border:1px solid rgba(0,0,0,.05);box-shadow:0 18px 54px rgba(147,197,253,.18)}
.shadow-glow{box-shadow:0 18px 54px rgba(167,243,208,.25)}

.tnw-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.tnw-span-2{grid-column:span 2}
.tnw-label{display:block;font-weight:800;color:#0b2039;margin:8px 0}
.tnw-input{width:100%;padding:12px 14px;border-radius:14px;background:#fff;border:1px solid #d1d5db;color:#111827;box-shadow:inset 0 1px 0 rgba(255,255,255,.6);transition:border .15s,box-shadow .15s}
.tnw-input:focus{outline:none;border-color:#93c5fd;box-shadow:0 0 0 3px rgba(147,197,253,.25)}
.tnw-range{-webkit-appearance:none;width:100%;height:14px;background:linear-gradient(90deg,#e5e7eb,#f3f4f6);border-radius:999px;outline:none;box-shadow:inset 0 1px 0 rgba(0,0,0,.04),0 1px 2px rgba(0,0,0,.06)}
.tnw-range::-webkit-slider-thumb{-webkit-appearance:none;width:26px;height:26px;border-radius:50%;background:radial-gradient(circle at 30% 30%,#fff,#e2e8f0);border:2px solid #93c5fd;box-shadow:0 6px 12px rgba(147,197,253,.45);cursor:pointer}
.tnw-range::-moz-range-thumb{width:26px;height:26px;border-radius:50%;background:#fff;border:2px solid #93c5fd;box-shadow:0 6px 12px rgba(147,197,253,.45);cursor:pointer}
.tnw-range-value{text-align:center;margin-top:6px;font-weight:900;color:#10365a;font-size:20px}
.tnw-check{display:flex;align-items:center;gap:10px;padding:12px}
.tnw-check.tnw-info{background:#f1f5f9;border-radius:14px;border:1px solid #e2e8f0}
.tnw-checkbox{width:20px;height:20px;accent-color:#86efac}
.tnw-conditional{max-height:0;overflow:hidden;opacity:0;transition:max-height .5s,opacity .3s}
.tnw-conditional.visible{max-height:620px;opacity:1}
.tnw-center{text-align:center;margin-top:16px}
.tnw-btn-3d{display:inline-block;padding:19px 26px;border-radius:999px;border:0;font-weight:900;letter-spacing:.5px;color:#0b1220;background:linear-gradient(90deg,var(--c2),var(--c4),var(--c3));box-shadow:0 18px 40px rgba(147,197,253,.28), inset 0 2px 0 rgba(255,255,255,.6);transform:translateY(0);transition:transform .15s,filter .15s,box-shadow .2s;cursor:pointer}
.tnw-btn-3d:hover{filter:brightness(1.06);transform:translateY(-2px)}
.tnw-btn-3d:active{transform:translateY(0)}
.tnw-loader{display:inline-block;width:80px;height:80px;border-radius:50%;border:5px solid #bfdbfe;border-top-color:#93c5fd;animation:spin 1s linear infinite;margin-bottom:10px}
@keyframes spin{to{transform:rotate(360deg)}}
.tnw-muted{color:#64748b;margin-top:6px}
.tnw-error{text-align:center;padding:14px;background:#fee2e2;color:#991b1b;border-radius:14px;border:1px solid #fecaca}

/* --- WYNIKI / TABELA --- */
#result-content .highlight{background:linear-gradient(135deg,#e0f2fe,#d1fae5);color:#0b2039;border-radius:16px;padding:16px;border:1px solid rgba(15,23,42,.08)}
#result-content h3{font-family:Poppins,sans-serif;color:#0b2039;font-size:18.2px;font-weight:900;text-align:center;margin:12px 0}
#result-content h4{color:#0b2039;font-size:12.6px;font-weight:800;margin:10px 0}
#result-content .card{background:#fff;border-radius:16px;border:1px solid #e5e7eb;padding:14px;box-shadow:0 8px 24px rgba(0,0,0,.06)}
#result-content table{width:100%;border-collapse:separate;border-spacing:0 2px;table-layout:auto}
#result-content thead th{background:#f3f4f6;font-size:8.4px;text-transform:uppercase;letter-spacing:.5px;padding:10px}
#result-content tbody td{background:#fff;border:1px solid #e5e7eb;padding:10px}

/* --- PODSUMOWANIE --- */
#result-content .summary{position:sticky;top:20px;z-index:5;background:linear-gradient(135deg,#0ea5e9,#34d399);color:#fff;border-radius:16px;padding:16px;border:1px solid rgba(255,255,255,.2);box-shadow:0 18px 48px rgba(0,0,0,.25)}
#result-content .summary .grid{display:grid;grid-template-columns:repeat(4,1fr);gap:12px}
#result-content .summary .box{background:rgba(255,255,255,.1);border:1px solid rgba(255,255,255,.18);border-radius:12px;padding:10px}
#result-content .summary p{margin:4px 0}
#result-content .summary .accent{color:#a7f3d0;font-weight:900;font-size:22px}
#result-content .summary .gold{color:#fde68a;font-weight:900;font-size:22px}
#result-content .summary .big{font-size:38px;font-weight:900;text-align:center;margin-top:6px}

/* --- ZAKŁADKI --- */
#subsidy-tabs{display:flex;flex-wrap:wrap;gap:8px;border-bottom:1px solid #e5e7eb;padding-bottom:8px;margin-top:14px}
#subsidy-tabs .tab-button{appearance:none;border:0;background:#fff;border-radius:12px;padding:10px 14px;cursor:pointer;font-weight:800;color:#0b2039;border:1px solid #e5e7eb}
#subsidy-tabs .tab-button.active{background:#0ea5e9;color:#fff;border-color:#0ea5e9}

/* --- KONTAKT --- */
.tnw-contact{margin-top:20px;border-radius:16px;padding:14px}
.tnw-contact h3{margin:0 0 8px 0;font-family:Poppins,sans-serif;font-weight:900;color:#0b2039}

/* === Interaktywny Kalkulator Dotacji – GRID (wariant 2) === */
#modernization-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
#modernization-grid .mod-heading{
  grid-column: 1 / -1;
  font-family:Poppins,system-ui,Arial,sans-serif;
  font-weight:800;
  font-size: var(--mod-head-size);
  color:#0b2039;
  margin: 4px 0 8px;
}
#modernization-grid .mod-option{
  display:flex; align-items:center; gap:12px;
  padding:14px 16px;
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:14px;
  box-shadow:0 8px 18px rgba(0,0,0,.05);
  font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  font-size: var(--mod-item-size);
  line-height:1.35;
  transition:border .15s, box-shadow .15s, background .15s;
}
#modernization-grid .mod-option:hover{
  border-color:#93c5fd; box-shadow:0 0 0 3px rgba(147,197,253,.18);
}
#modernization-grid .mod-option:has(input:checked){
  background:#f0f9ff; border-color:#93c5fd;
}
#modernization-grid .mod-option input{
  width:20px; height:20px; flex:0 0 auto; accent-color:#0ea5e9;
}

/* =====================================================
   PORTRET = ten sam układ jak w poziomie, tylko skala
   full-bleed + dynamiczna szerokość => zero pustych boków
   ===================================================== */
@media (max-width:980px) and (orientation:portrait){
  :root{ --ui-scale: var(--portrait-scale); }

  #tnw-doradca-prosty.tnw-shell{
    width:100vw;
    margin-left:calc(50% - 50vw);
    margin-right:calc(50% - 50vw);
  }

  .tnw-container{
    width:calc(100vw / var(--ui-scale));
    max-width:calc(100vw / var(--ui-scale));
    margin:0 auto;
    padding-inline:clamp(1px,1.6vw,12px); /* ciaśniejsze boczne */
    transform:scale(var(--ui-scale));
    -webkit-transform:scale(var(--ui-scale));
    transform-origin: top center;
    will-change:transform;
  }

  /* zachowujemy 2 kolumny jak w poziomie */
  .tnw-grid{grid-template-columns:1fr 1fr;gap:14px}

  /* (stare #modernization-options-container pozostaje bez zmian) */

  /* sticky działa jak w poziomie */
  #result-content .summary{position:sticky;top:18px}

  /* ciaśniej pionowo */
  .tnw-header{padding:40px 0 16px}
  .tnw-main{padding:6px 0 20px}
  .tnw-card{padding:10px;border-radius:18px}
  .tnw-title { font-size: 24px; }
  .tnw-label { font-size: 16px; }
  .tnw-range-value { font-size: 18px; }
  .tnw-input { font-size: 16px; }
  #result-content h3 { font-size: 15.4px; }
  #result-content .summary .accent,
  #result-content .summary .gold { font-size: 20px; }
  #result-content .summary .big { font-size: 82px; }
}

@media (max-width:980px){
  /* Grid wariant 2: jedna kolumna + mniejsze fonty */
  #modernization-grid{ grid-template-columns: 1fr; }
  :root{ --mod-head-size: 15px; --mod-item-size: var(--mod-item-size-sm); }
}
@media (max-width:640px){
  :root{ --mod-head-size: 14px; --mod-item-size-sm: 12.5px; }
}

@media (max-width: 768px) {
  #p1, #p2, #p3 {
    left: 0;
    right: 0;
  }
}

/* TABLET/LAPTOP landscape – drobna korekta */
@media (max-width:1200px) and (orientation:landscape){
  .tnw-container{max-width:96vw}
}

/* reduced motion */
@media (prefers-reduced-motion:reduce){
  .parallax-blob{animation:none !important}
  .tnw-btn-3d{transition:none}
}

#result-content p:not(.summary .accent):not(.summary .gold):not(.summary .big) {
  font-size: 16px; /* 30% reduction from 16px */
}

/* safe area */
.tnw-shell{padding-bottom:calc(env(safe-area-inset-bottom,0px)+6px)}

/* === TABELA WYNIKÓW – typografia sterowana zmiennymi === */
#tnw-doradca-prosty #result-content table,
#tnw-doradca-prosty #result-content thead th,
#tnw-doradca-prosty #result-content tbody td{
  font-family: var(--tnw-table-font);
  line-height: var(--tnw-table-line);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
}

/* NAGŁÓWKI */
#tnw-doradca-prosty #result-content thead th{
  font-size: var(--tnw-th-size);
  font-weight: var(--tnw-th-weight);
}

/* KOMÓRKI */
#tnw-doradca-prosty #result-content tbody td{
  font-size: var(--tnw-td-size);
  font-weight: var(--tnw-td-weight);
}

/* Mobile (<=640px) – mniejsze rozmiary, bez zagnieżdżania @media */
@media (max-width: 640px){
  /* PRZED – pierwsza karta po H3 */
  #tnw-doradca-prosty #result-content h3 + .card table thead th{ font-size: 10.5px; }
  #tnw-doradca-prosty #result-content h3 + .card table tbody td{ font-size: 9.5px; }

  /* PO – druga karta po H3 */
  #tnw-doradca-prosty #result-content h3 + .card + .card table thead th{ font-size: 10.5px; }
  #tnw-doradca-prosty #result-content h3 + .card + .card table tbody td{ font-size: 9.5px; }
}
