/* ==========================================================================
   /tools/tax-deduction
   Inherits hero/FAQ/tip base from maternity-bag.css
   ========================================================================== */
@import url("/assets/css/maternity-bag.css");

/* ---------- Page & Hero ---------- */
.td-page {
  background: #f7f8fb !important;
}

.td-hero {
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.6) 0%,
      rgba(247, 232, 198, 0.78) 100%
    ),
    linear-gradient(180deg, #ffffff 0%, #f3e9c8 100%) !important;
  border-bottom-color: #e8dcb0 !important;
}

.td-hero .mb-hero-title span::after {
  background: linear-gradient(
    90deg,
    rgba(189, 160, 0, 0.45),
    rgba(247, 203, 202, 0.4)
  );
}

.td-form-section {
  margin-bottom: 0 !important;
}

/* ==========================================================================
   FORM
   ========================================================================== */
.td-form-card {
  background: #fff;
  border: 1px solid #ece5d0;
  border-radius: 20px;
  padding: 32px 36px;
  margin: 0 0 12px;
  box-shadow: 0 4px 20px rgba(17, 17, 17, 0.04);
}

.td-form-title {
  font-family: "Montserrat", sans-serif;
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 24px !important;
  color: var(--main-bg-color);
}

.td-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.td-field-full {
  grid-column: 1 / -1;
}

.td-field label {
  display: block;
  font-family: "Montserrat", sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--main-bg-color);
  margin-bottom: 8px;
}

.td-field input,
.td-field select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #ece5d0;
  border-radius: 12px;
  font-family: "Nunito", sans-serif;
  font-size: 16px;
  color: var(--main-bg-color);
  background: #fafbfc;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.td-field select {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.td-field input:focus,
.td-field select:focus {
  outline: none;
  border-color: var(--gold-color);
  box-shadow: 0 0 0 3px rgba(189, 160, 0, 0.18);
}

.td-field-hint {
  display: block;
  margin-top: 6px;
  font-size: 12.5px;
  color: #777;
  line-height: 1.4;
}

/* ---------- Кастомный select ---------- */
.td-select {
  position: relative;
}

.td-select .td-select-native {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.td-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid #ece5d0;
  border-radius: 12px;
  font-family: "Nunito", sans-serif;
  font-size: 16px;
  color: var(--main-bg-color);
  background: #fafbfc;
  cursor: pointer;
  text-align: left;
  line-height: 1.3;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.td-select-trigger:hover {
  border-color: #ddd1a8;
}

.td-select-trigger:focus-visible,
.td-select[data-open="true"] .td-select-trigger {
  outline: none;
  border-color: var(--gold-color);
  box-shadow: 0 0 0 3px rgba(189, 160, 0, 0.18);
}

.td-select-value {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-select-caret {
  flex-shrink: 0;
  color: #999;
  transition:
    transform 0.22s ease,
    color 0.18s;
}

.td-select[data-open="true"] .td-select-caret {
  transform: rotate(180deg);
  color: var(--gold-color);
}

.td-select-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ece5d0;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(17, 17, 17, 0.12);
  padding: 6px;
  margin: 0;
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top center;
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.td-select[data-open="true"] .td-select-menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.td-select-option {
  padding: 11px 14px;
  border-radius: 8px;
  font-family: "Nunito", sans-serif;
  font-size: 15px;
  color: var(--main-bg-color);
  cursor: pointer;
  line-height: 1.4;
  transition:
    background 0.12s,
    color 0.12s;
  user-select: none;
}

.td-select-option:hover,
.td-select-option.is-focused {
  background: #faf2d4;
}

.td-select-option[aria-selected="true"] {
  background: var(--gold-color);
  color: #fff;
  font-weight: 600;
}

.td-select-option[aria-selected="true"]:hover,
.td-select-option[aria-selected="true"].is-focused {
  background: #a48b00;
}

/* ---------- Children block ---------- */
.td-children {
  border-top: 1px dashed #ece5d0;
  padding-top: 24px;
  margin-bottom: 24px;
}

.td-children-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 14px;
}

.td-children-head h3 {
  font-family: "Montserrat", sans-serif;
  font-size: 17px;
  font-weight: 700;
  margin: 0 !important;
  color: var(--main-bg-color);
}

.td-children-hint {
  font-size: 12.5px;
  color: #777;
}

.td-children-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.td-child {
  display: grid;
  grid-template-columns: 36px 1fr 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #fafbfc;
  border: 1px solid #ece5d0;
  border-radius: 14px;
  transition:
    border-color 0.2s,
    background 0.2s;
}

.td-child:hover {
  border-color: #ddd1a8;
}

.td-child-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold-color);
  color: #fff;
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.td-child-age {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.td-child-age label {
  font-size: 11.5px;
  font-weight: 600;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}

.td-child-age input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  font-family: "Nunito", sans-serif;
  width: 100%;
  background: #fff;
}

.td-child-age input:focus {
  outline: none;
  border-color: var(--gold-color);
}

.td-child-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.td-child-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #444;
  cursor: pointer;
  user-select: none;
}

.td-child-flag input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.5px solid #cfc7a8;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background 0.15s,
    border-color 0.15s,
    box-shadow 0.15s;
}

.td-child-flag input[type="checkbox"]:hover {
  border-color: var(--gold-color);
}

.td-child-flag input[type="checkbox"]:checked {
  background-color: var(--gold-color);
  border-color: var(--gold-color);
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='10' viewBox='0 0 12 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 5L4.5 8.5L11 1.5' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.td-child-flag input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(189, 160, 0, 0.25);
}

.td-child-flag[data-hidden="true"] {
  display: none;
}

.td-child-remove {
  background: none;
  border: 1px solid #e2c4c3;
  color: #b85c5a;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.td-child-remove:hover {
  background: #fff0ef;
  border-color: #c98886;
}

.td-add-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1.5px dashed var(--gold-color);
  color: var(--gold-color);
  padding: 10px 18px;
  border-radius: 999px;
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    border-style 0.15s;
}

.td-add-child:hover {
  background: var(--gold-color);
  color: #fff;
  border-style: solid;
}

.td-add-child[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Calculate button ---------- */
.td-calc-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  background: var(--main-bg-color);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.1s;
}

.td-calc-btn:hover {
  background: #000;
}

.td-calc-btn:active {
  transform: scale(0.99);
}

.td-calc-btn:disabled {
  background: #aaa;
  cursor: not-allowed;
}

/* ==========================================================================
   RESULTS
   ========================================================================== */
.td-results {
  margin: 28px 0 36px;
}

.td-results-title {
  font-family: "Montserrat", sans-serif;
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 20px !important;
  color: var(--main-bg-color);
}

.td-total-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.td-total-card {
  background: #fff;
  border-radius: 18px;
  padding: 22px 26px;
  border: 1px solid #ece5d0;
  box-shadow: 0 4px 16px rgba(17, 17, 17, 0.04);
}

.td-total-month {
  background: linear-gradient(135deg, #fff 0%, #fdf6dd 100%);
  border-color: #e8dcb0;
}

.td-total-year {
  background: linear-gradient(135deg, #fff 0%, #ffe5e4 100%);
  border-color: #f0caca;
}

.td-total-label {
  font-family: "Montserrat", sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.td-total-amount {
  font-family: "Montserrat", sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--main-bg-color);
  line-height: 1.1;
  margin-bottom: 6px;
  word-break: keep-all;
}

.td-total-hint {
  font-size: 13px;
  color: #666;
}

/* ---------- Months chart ---------- */
.td-months-chart {
  background: #fff;
  border: 1px solid #ece5d0;
  border-radius: 18px;
  padding: 20px 24px 22px;
  margin-bottom: 24px;
}

.td-months-chart-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 14px;
}

.td-months-chart-title {
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--main-bg-color);
}

.td-months-chart-legend {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12.5px;
  color: #666;
}

.td-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.td-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.td-legend-on {
  background: var(--gold-color);
}

.td-legend-off {
  background: #ddd;
}

.td-months-row {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.td-month-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: #ececec;
  color: #888;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: "Montserrat", sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  transition: transform 0.15s;
}

.td-month-cell.is-on {
  background: var(--gold-color);
  color: #fff;
}

.td-month-cell .td-month-amount {
  font-size: 10px;
  font-weight: 500;
  margin-top: 2px;
  opacity: 0.85;
}

.td-months-foot {
  font-size: 13px;
  color: #555;
  line-height: 1.5;
}

.td-months-foot strong {
  color: var(--main-bg-color);
}

/* ---------- Breakdown ---------- */
.td-breakdown {
  background: #fff;
  border: 1px solid #ece5d0;
  border-radius: 18px;
  padding: 20px 24px;
  margin-bottom: 24px;
}

.td-breakdown h3 {
  font-family: "Montserrat", sans-serif;
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 14px !important;
  color: var(--main-bg-color);
}

.td-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Nunito", sans-serif;
}

.td-breakdown-table th,
.td-breakdown-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #f0eada;
  font-size: 14.5px;
}

.td-breakdown-table th {
  font-family: "Montserrat", sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #777;
  background: #fbf7e8;
}

.td-breakdown-table tbody tr:last-child td {
  border-bottom: none;
}

.td-breakdown-table tbody tr.is-skipped td {
  color: #aaa;
  background: #fafafa;
}

.td-breakdown-table .td-breakdown-amount {
  font-weight: 700;
  color: var(--main-bg-color);
  white-space: nowrap;
}

.td-breakdown-note {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fdf6dd;
  border-left: 3px solid var(--gold-color);
  border-radius: 6px;
  font-size: 13.5px;
  color: #555;
}

/* ---------- Reference table ---------- */
.td-ref-table {
  background: #fff;
  border: 1px solid #ece5d0;
  border-radius: 18px;
  padding: 20px 24px;
}

.td-ref-table h3 {
  font-family: "Montserrat", sans-serif;
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 14px !important;
  color: var(--main-bg-color);
}

.td-ref-table table {
  width: 100%;
  border-collapse: collapse;
}

.td-ref-table td {
  padding: 8px 0;
  font-size: 14.5px;
  font-family: "Nunito", sans-serif;
  border-bottom: 1px solid #f0eada;
}

.td-ref-table td:last-child {
  text-align: right;
}

.td-ref-table tr:last-child td {
  border-bottom: none;
}

/* ---------- Share button (override icon-only padding) ---------- */
.td-share {
  margin: 0 0 12px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
  .td-form-card {
    padding: 22px 18px;
  }
  .td-form-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .td-field {
    min-width: 0; /* чтобы grid-item мог сжиматься, не вылезая за родителя */
  }
  .td-select-value {
    white-space: normal; /* разрешаем перенос длинных опций в триггере */
    text-overflow: clip;
    overflow: visible;
  }
  .td-total-grid {
    grid-template-columns: 1fr;
  }
  .td-total-amount {
    font-size: 26px;
  }
  .td-child {
    grid-template-columns: 36px 1fr auto;
    gap: 10px;
  }
  .td-child-flags {
    grid-column: 1 / -1;
    padding-left: 46px;
  }
  .td-months-row {
    grid-template-columns: repeat(6, 1fr);
  }
  .td-month-cell {
    aspect-ratio: auto;
    padding: 6px 4px;
  }
  .td-breakdown-table th:nth-child(2),
  .td-breakdown-table td:nth-child(2),
  .td-breakdown-table th:nth-child(3),
  .td-breakdown-table td:nth-child(3) {
    display: none;
  }
}

@media (max-width: 576px) {
  .td-form-card {
    padding: 18px 14px;
  }
  .td-form-title {
    font-size: 19px;
  }
  .td-field input,
  .td-select-trigger {
    padding: 12px 14px;
    font-size: 15px;
  }
  .td-select-trigger {
    gap: 8px;
  }
  .td-select-option {
    padding: 10px 12px;
    font-size: 14px;
  }
  .td-children-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .td-total-amount {
    font-size: 22px;
  }
  .td-month-cell {
    font-size: 10px;
  }
  .td-month-cell .td-month-amount {
    display: none;
  }
}

@media (max-width: 380px) {
  .td-form-card {
    padding: 16px 12px;
    border-radius: 16px;
  }
  .td-field input,
  .td-select-trigger {
    padding: 11px 12px;
    font-size: 14.5px;
  }
}

/* ==========================================================================
   SOURCES — academic references block (shared pattern from school-readiness)
   ========================================================================== */
.sr-sources-block {
  margin: 32px 0 8px;
  padding: 26px 30px 22px !important;
  background: linear-gradient(180deg, #ffffff 0%, #faf8f1 100%);
  border: 1px solid #ece5cf;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(189, 160, 0, 0.05);
}

.sr-sources-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px dashed #e3dcc2;
}

.sr-sources-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--gold-color);
  color: #fff;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(189, 160, 0, 0.25);
}

.sr-sources-head h2 {
  font-family: "Montserrat", sans-serif;
  font-size: 20px !important;
  font-weight: 800 !important;
  margin: 0 !important;
  letter-spacing: -0.02em;
  color: var(--main-bg-color);
}

.sr-sources {
  counter-reset: sr-source;
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  font-size: 13.5px !important;
  line-height: 1.6 !important;
  color: var(--main-bg-color);
}

.sr-sources li {
  position: relative;
  counter-increment: sr-source;
  padding: 10px 12px 10px 42px !important;
  margin: 0 !important;
  border-radius: 10px;
  transition: background 0.2s ease;
}

.sr-sources li:hover {
  background: rgba(189, 160, 0, 0.04);
}

.sr-sources li::before {
  content: counter(sr-source);
  position: absolute;
  left: 8px;
  top: 9px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1.5px solid #e3dcc2;
  border-radius: 50%;
  font-family: "Montserrat", sans-serif;
  font-size: 11px;
  font-weight: 800;
  color: var(--gold-color);
}

.sr-sources-authors {
  font-weight: 700;
  color: var(--main-bg-color);
  margin-right: 4px;
}

.sr-sources cite {
  font-style: italic;
  color: var(--main-bg-color);
}

.sr-sources a {
  color: var(--main-bg-color);
  text-decoration: underline;
  text-decoration-color: rgba(189, 160, 0, 0.5);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
  transition:
    text-decoration-color 0.2s,
    color 0.2s;
}

.sr-sources a:hover {
  color: #8a7600;
  text-decoration-color: var(--gold-color);
}

.sr-sources a[target="_blank"]::after {
  content: "\2197";
  display: inline-block;
  margin-left: 3px;
  font-size: 0.85em;
  color: var(--gold-color);
  text-decoration: none;
  vertical-align: middle;
}

.sr-sources-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  background: rgba(189, 160, 0, 0.12);
  color: #8a7600;
  border-radius: 999px;
  font-family: "Montserrat", sans-serif;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
  white-space: nowrap;
}

.sr-sources-note {
  margin: 16px 0 0 !important;
  padding: 10px 14px !important;
  background: rgba(255, 255, 255, 0.6);
  border-left: 3px solid var(--gold-color);
  border-radius: 8px;
  font-size: 12.5px !important;
  line-height: 1.5 !important;
  color: #444;
  font-style: italic;
}

@media (max-width: 700px) {
  .sr-sources-block {
    padding: 22px 18px 18px !important;
  }
  .sr-sources-head {
    gap: 10px;
  }
  .sr-sources-head h2 {
    font-size: 18px !important;
  }
  .sr-sources li {
    padding: 10px 8px 10px 38px !important;
    font-size: 13px !important;
  }
  .sr-sources li::before {
    left: 4px;
    top: 10px;
    width: 22px;
    height: 22px;
  }
}

/* ==========================================================================
   WIDGET (embedded in articles)
   ========================================================================== */
.tool-widget-td {
  background: linear-gradient(135deg, #fdf6dd 0%, #ffe5e4 100%);
  border: 1px solid #e8dcb0;
}

.tool-widget-td .tool-widget-tag {
  background: var(--gold-color);
  color: #fff;
}

.tool-widget-td .tool-widget-bag em {
  color: #8a7400;
}
