.terlan-kalk {
    border: 1px solid #e6e6e6;
    border-radius: 14px;
    padding: 18px;
    max-width: 980px;
}

.terlan-kalk__header {
    margin-bottom: 14px;
}

.terlan-kalk__title {
    margin: 0;
    font-size: 20px;
}

.terlan-kalk__subtitle {
    margin: 6px 0 0;
    opacity: .75;
}

.terlan-kalk__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

@media (max-width: 780px) {
    .terlan-kalk__grid {
        grid-template-columns: 1fr;
    }
}

.terlan-kalk__card {
    border: 1px solid #eee;
    border-radius: 14px;
    padding: 14px;
    background: #fff;
}

.terlan-kalk__field {
    margin-bottom: 12px;
}

.terlan-kalk__label {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
    opacity: .85;
}

.terlan-kalk__input {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
}

.terlan-kalk__hint {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px;
    opacity: .7;
}

.terlan-kalk__section {
    margin: 0 0 10px;
    font-size: 16px;
}

.terlan-kalk__kpi {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.terlan-kalk__kpi-item {
    padding: 10px 12px;
    border: 1px dashed #e7e7e7;
    border-radius: 12px;
}

.terlan-kalk__kpi-label {
    font-size: 12px;
    opacity: .75;
}

.terlan-kalk__kpi-value {
    font-size: 18px;
    margin-top: 4px;
    font-weight: 600;
}

/* Rozbicie korzyści w podsumowaniu */
.terlan-kalk__kpi-breakdown{
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #efefef;
    display: grid;
    gap: 6px;
}

.terlan-kalk__kpi-row{
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.terlan-kalk__kpi-small-label{
    font-size: 12px;
    opacity: .8;
    line-height: 1.2;
}

.terlan-kalk__kpi-small-value{
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* Wykres słupkowy: korzyść/strata po 1. roku (ujemne = w lewo) */
.terlan-kalk__benefitchart{
    margin-top: 10px;
}

.terlan-kalk__benefitchart-axis{
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.terlan-kalk__benefitchart-txt{
    font-size: 11px;
    line-height: 1;
    opacity: .7;
}

.terlan-kalk__benefitchart-txt--neg{ text-align: left; }
.terlan-kalk__benefitchart-txt--zero{ text-align: center; }
.terlan-kalk__benefitchart-txt--pos{ text-align: right; }

.terlan-kalk__benefitchart-track{
    position: relative;
    height: 16px;
    border-radius: 999px;
    background: #f3f4f6;
    overflow: hidden;
}

.terlan-kalk__benefitchart-track::after{
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background: #d1d5db;
}

.terlan-kalk__benefitchart-bar{
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 0;
    background: #16a34a;
}

.terlan-kalk__benefitchart-bar.is-neg{
    left: auto;
    right: 50%;
    background: #dc2626;
}

.terlan-kalk__tablewrap {
    margin-top: 14px;
    overflow: auto;
}

.terlan-kalk__table {
    width: 100%;
    border-collapse: collapse;
    min-width: 100%;
}

.terlan-kalk__table th,
.terlan-kalk__table td {
    border-bottom: 1px solid #eee;
    padding: 10px 12px;
    text-align: left;
}

.terlan-kalk__row-total td {
    font-weight: 700;
    border-top: 2px solid #ddd;
}

.terlan-kalk__notes {
    margin-top: 14px;
    display: grid;
    gap: 8px;
}

.terlan-kalk__note {
    padding: 10px 12px;
    border-radius: 12px;
    background: #fafafa;
    border: 1px solid #f0f0f0;
}

.terlan-kalk__divider {
    height: 1px;
    background: #eee;
    margin: 14px 0;
}

.terlan-kalk__input--ro {
    background: #fafafa;
    border-style: dashed;
    opacity: .9;
    cursor: not-allowed;
}

.terlan-kalk__tabletitle {
    font-weight: 700;
    margin: 4px 0 10px;
}

.terlan-kalk__row-total td {
    font-weight: 700;
    border-top: 2px solid #eee;
}

.terlan-kalk__row-strong td {
    font-weight: 700;
}

.terlan-kalk__block {
    margin-top: 18px;
    padding: 14px;
    border: 1px solid #eee;
    border-radius: 14px;
    background: #fff;
}

.terlan-kalk__block-title {
    font-weight: 700;
    text-align: center;
    margin-bottom: 10px;
    background: #f3f3f3;
    border-radius: 10px;
    padding: 8px 10px;
}

.terlan-kalk__block-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 6px 0;
    flex-wrap: wrap;
}

.terlan-kalk__block-note {
    opacity: .85;
}

.terlan-kalk__sr-only{
  position:absolute;
  width:1px;height:1px;
  padding:0;margin:-1px;
  overflow:hidden;clip:rect(0,0,0,0);
  white-space:nowrap;border:0;
}


/* ===== TABELA: stałe szerokości kolumn 50/25/25 ===== */
.terlan-kalk__table {
  width: 100%;
  table-layout: fixed; /* kluczowe */
}

.terlan-kalk__table th,
.terlan-kalk__table td {
  vertical-align: top;
}

/* 1. kolumna (label) 50% */
.terlan-kalk__table th:first-child,
.terlan-kalk__table td:first-child {
  width: 50%;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Komcel i Minerał po 25% */
.terlan-kalk__table th:nth-child(2),
.terlan-kalk__table td:nth-child(2),
.terlan-kalk__table th:nth-child(3),
.terlan-kalk__table td:nth-child(3) {
  width: 25%;
}

/* wartości wyrównane do prawej, żeby wyglądało jak w Excelu */
.terlan-kalk__table td:nth-child(2),
.terlan-kalk__table td:nth-child(3),
.terlan-kalk__table th:nth-child(2),
.terlan-kalk__table th:nth-child(3) {
  text-align: right;
}

/* na mobile daj trochę mniejsze paddingi, żeby nie pchało */
@media (max-width: 640px) {
  .terlan-kalk__table th,
  .terlan-kalk__table td {
    padding: 10px 8px;
  }
}


/* ===== KORZYŚCI: scalone komórki jak w Excelu (pod "Komcel") ===== */
.terlan-kalk__row-benefits-start td{
  border-top: 2px solid #ddd; /* wizualne rozdzielenie kosztów i korzyści */
}

.terlan-kalk__cell-benefit{
  text-align: left !important;        /* zaczyna się od lewej krawędzi */
  background: #fff6bf;                /* delikatny żółty jak w Excelu */
  white-space: normal;
}

.terlan-kalk__cell-benefit-total{
  font-size: 16px;
}

/* ===== WYKRES KOSZTÓW (Z JEDNOSTKAMI / LEGENDĄ) ===== */
.terlan-kalk__barswrap{
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.terlan-kalk__barshead{
  display:flex;
  align-items:flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.terlan-kalk__barstitle{
  font-size: 13px;
  font-weight: 600;
  opacity: .9;
}

.terlan-kalk__barslegend{
  display:flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.terlan-kalk__legenditem{
  display:inline-flex;
  align-items:center;
  gap: 6px;
  font-size: 12px;
  opacity: .85;
  white-space: nowrap;
}

.terlan-kalk__dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display:inline-block;
}

.terlan-kalk__dot--komcel{
  background: linear-gradient(90deg, #2e7d32 0%, #8d6e63 100%);
}

.terlan-kalk__dot--mineral{
  background: #d32f2f;
}

.terlan-kalk__bars-toggle{
  display:flex;
  gap: 8px;
  margin: 10px 0 6px;
}

.terlan-kalk__bars-btn{
  appearance: none;
  border: 1px solid #e5e5e5;
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.terlan-kalk__bars-btn.is-active{
  border-color: #cfcfcf;
  background: #f6f6f6;
}

.terlan-kalk__bars{
  display:block;
}

.terlan-kalk__barrow{
  display:flex;
  flex-wrap: wrap;
  align-items:center;
  gap: 6px 10px;
  margin: 10px 0;
}

.terlan-kalk__barlabel{
  width: auto;
  flex: 1 1 auto;
  min-width: 120px;
  font-size: 13px;
  opacity: .85;
  order: 1;
}

.terlan-kalk__barvalue{
  width: auto;
  flex: 0 0 auto;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  opacity: .95;
  white-space: nowrap;
  order: 2;
}

.terlan-kalk__bar{
  flex: 1 1 100%;
  order: 3;
  height: 10px;
  background: #e9e9e9;
  border-radius: 999px;
  overflow: hidden;
}

.terlan-kalk__barfill{
  display:block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width .35s ease;
}

/* Komcel: zielony → brązowy */
.terlan-kalk__barfill--komcel{
  background: linear-gradient(90deg, #2e7d32 0%, #8d6e63 100%);
}

/* Nawóz mineralny: czerwony */
.terlan-kalk__barfill--mineral{
  background: #d32f2f;
}

/* ===== WIDOK PIONOWY ===== */
.terlan-kalk__vbars{
  display:none;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 10px;
  align-items: end;
}

.terlan-kalk__vbar{
  display:flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.terlan-kalk__vbarcol{
  height: 120px;
  background: #e9e9e9;
  border-radius: 18px;
  overflow: hidden;
  display:flex;
  align-items:flex-end;
  width: 100%;
  max-width: 220px;
}

.terlan-kalk__vbarfill{
  display:block;
  width: 100%;
  height: 0;
  transition: height .35s ease;
}

.terlan-kalk__vbarfill--komcel{
  background: linear-gradient(180deg, #2e7d32 0%, #8d6e63 100%);
}

.terlan-kalk__vbarfill--mineral{
  background: #d32f2f;
}

.terlan-kalk__vbarlabel{
  font-size: 12px;
  opacity: .85;
  text-align: center;
}

.terlan-kalk__vbarvalue{
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* przełączanie widoku */
[data-terlan-bars-mode="vertical"]{ display:none; }
.terlan-kalk.is-bars-vertical [data-terlan-bars-mode="horizontal"]{ display:none; }
.terlan-kalk.is-bars-vertical [data-terlan-bars-mode="vertical"]{ display:grid; }

@media (max-width: 640px) {
  .terlan-kalk__barlabel{
    width: 120px;
  }
  .terlan-kalk__barvalue{
    width: 96px;
  }
}
