:root {
  --ik-template-ink: #172033;
  --ik-template-muted: #5d6677;
  --ik-template-line: #cfd5df;
  --ik-template-soft: #f4f6f9;
  --ik-template-accent: #165d54;
}

.ik-template-shell,
.ik-template-shell * {
  box-sizing: border-box;
}

.ik-template-shell {
  width: 100%;
  max-width: 210mm;
  margin: 0 auto;
  color: var(--ik-template-ink);
  direction: rtl;
  font-family: inherit;
}

.ik-template__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1rem;
}

.ik-template__actions p {
  margin: 0;
  color: var(--ik-template-muted);
  font-size: 0.9rem;
}

.ik-template__print {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0.7rem 1rem;
  border: 0;
  border-radius: 0.65rem;
  background: var(--ik-template-accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.ik-template__print:hover,
.ik-template__print:focus-visible {
  filter: brightness(0.92);
}

.ik-template__print:focus-visible {
  outline: 3px solid #8fcfc5;
  outline-offset: 3px;
}

.ik-template-sheet {
  width: 100%;
  min-height: 270mm;
  padding: clamp(1rem, 3vw, 2rem);
  border: 1px solid var(--ik-template-line);
  border-radius: 0.75rem;
  background: #fff;
  box-shadow: 0 10px 28px rgba(23, 32, 51, 0.08);
}

.ik-template__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(13rem, 0.7fr);
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 2px solid var(--ik-template-ink);
}

.ik-template__header h2 {
  margin: 0 0 0.3rem;
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.ik-template__header p {
  margin: 0;
  color: var(--ik-template-muted);
}

.ik-template__meta,
.ik-template__summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.ik-template__field {
  display: grid;
  gap: 0.3rem;
  font-weight: 700;
}

.ik-template__field input,
.ik-template__field textarea,
.ik-template__amount {
  width: 100%;
  min-width: 0;
  min-height: 2.35rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--ik-template-line);
  border-radius: 0.4rem;
  background: #fff;
  color: var(--ik-template-ink);
  font: inherit;
}

.ik-template__field input:focus,
.ik-template__field textarea:focus,
.ik-template__amount:focus {
  border-color: var(--ik-template-accent);
  outline: 3px solid rgba(22, 93, 84, 0.16);
}

.ik-template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.ik-template-section {
  min-width: 0;
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--ik-template-line);
  border-radius: 0.55rem;
}

.ik-template-section legend {
  padding: 0 0.35rem;
  color: var(--ik-template-accent);
  font-weight: 800;
}

.ik-template__row {
  display: grid;
  grid-template-columns: minmax(6.5rem, 1.2fr) repeat(2, minmax(0, 0.8fr));
  gap: 0.4rem;
  align-items: center;
  padding: 0.28rem 0;
  border-bottom: 1px solid #e8ebf0;
}

.ik-template__row:last-child {
  border-bottom: 0;
}

.ik-template__row--head {
  color: var(--ik-template-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.ik-template__item {
  min-width: 0;
  font-size: 0.9rem;
}

.ik-template__amount {
  min-height: 2rem;
  padding: 0.3rem 0.4rem;
  text-align: center;
}

.ik-template__header--single {
  grid-template-columns: 1fr;
}

.ik-template-section--wide {
  margin-bottom: 0.85rem;
}

.ik-template-table-wrap {
  min-width: 0;
}

.ik-template-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.ik-template-table th,
.ik-template-table td {
  padding: 0.35rem 0.25rem;
  border: 1px solid var(--ik-template-line);
  vertical-align: middle;
}

.ik-template-table th {
  background: var(--ik-template-soft);
  color: var(--ik-template-muted);
  font-size: 0.76rem;
  line-height: 1.35;
  text-align: center;
}

.ik-template-table td .ik-template__amount {
  min-height: 2rem;
  padding: 0.25rem;
  font-size: 0.78rem;
}

.ik-template-table td .ik-template__amount--text {
  text-align: start;
}

.ik-template-table__col--name {
  width: 22%;
}

.ik-template-table__col--initial,
.ik-template-table__col--remaining,
.ik-template-table__col--date {
  width: 14%;
}

.ik-template-table__col--payment,
.ik-template-table__col--paid,
.ik-template-table__col--status {
  width: 12%;
}

.ik-template__footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.85rem;
  margin-top: 0.85rem;
}

.ik-template__summary,
.ik-template__notes {
  padding: 0.75rem;
  border: 1px solid var(--ik-template-line);
  border-radius: 0.55rem;
  background: var(--ik-template-soft);
}

.ik-template__summary h3,
.ik-template__notes h3 {
  grid-column: 1 / -1;
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.ik-template__notes textarea {
  min-height: 7.2rem;
  resize: vertical;
}

.ik-template-shell[data-ik-template="financial-goal-planner"] .ik-financial-goal-planner__summary-fields {
  grid-template-columns: minmax(0, 1fr);
}

.ik-template-shell[data-ik-template="financial-goal-planner"] .ik-template__summary select {
  width: 100%;
  min-width: 0;
  min-height: 2.35rem;
  height: calc(1.5em + 0.9rem + 2px);
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--ik-template-line);
  border-radius: 0.4rem;
  background: #fff;
  color: var(--ik-template-ink);
  font: inherit;
  line-height: 1.5;
}

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

@media (max-width: 720px) {
  .ik-template__actions,
  .ik-template__header,
  .ik-template-grid,
  .ik-template__footer {
    grid-template-columns: 1fr;
  }

  .ik-template__actions {
    display: grid;
  }

  .ik-template__print {
    width: 100%;
  }

  .ik-template-sheet {
    min-height: 0;
    padding: 1rem;
  }

  .ik-template-table,
  .ik-template-table tbody,
  .ik-template-table tr,
  .ik-template-table td {
    display: block;
    width: 100%;
  }

  .ik-template-table colgroup,
  .ik-template-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .ik-template-table tbody {
    display: grid;
    gap: 0.8rem;
  }

  .ik-template-table tr {
    padding: 0.65rem;
    border: 1px solid var(--ik-template-line);
    border-radius: 0.5rem;
  }

  .ik-template-table td {
    display: grid;
    grid-template-columns: minmax(8.5rem, 0.8fr) minmax(0, 1fr);
    gap: 0.6rem;
    align-items: center;
    padding: 0.4rem 0;
    border: 0;
    border-bottom: 1px solid #e8ebf0;
  }

  .ik-template-table td:last-child {
    border-bottom: 0;
  }

  .ik-template-table td::before {
    content: attr(data-label);
    color: var(--ik-template-muted);
    font-size: 0.82rem;
    font-weight: 700;
  }
}

@media (max-width: 460px) {
  .ik-template__row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ik-template__item,
  .ik-template__row--head span:first-child {
    grid-column: 1 / -1;
  }

  .ik-template__row--head span:first-child {
    display: none;
  }

  .ik-template-table td {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}

@page {
  size: A4 portrait;
  margin: 10mm;
}

@media print {
  html,
  body {
    background: #fff !important;
  }

  body * {
    visibility: hidden !important;
  }

  .ik-template-shell,
  .ik-template-shell * {
    visibility: visible !important;
  }

  .ik-template-shell {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    color: #000;
  }

  .ik-template__actions {
    display: none !important;
  }

  .ik-template-sheet {
    width: 190mm;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .ik-template__header,
  .ik-template-grid,
  .ik-template__footer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ik-template__header {
    gap: 5mm;
    margin-bottom: 3mm;
    padding-bottom: 2mm;
  }

  .ik-template__header h2 {
    font-size: 17pt;
  }

  .ik-template-grid,
  .ik-template__footer {
    gap: 3mm;
  }

  .ik-template-section,
  .ik-template__summary,
  .ik-template__notes {
    break-inside: avoid-page;
    padding: 2.5mm;
    border-color: #777;
    background: #fff;
  }

  .ik-template__row {
    grid-template-columns: minmax(36mm, 1.2fr) repeat(2, minmax(0, 0.8fr));
    gap: 1.5mm;
    padding: 0.7mm 0;
    border-color: #bbb;
  }

  .ik-template__item,
  .ik-template__row--head span:first-child {
    display: inline;
    grid-column: auto;
  }

  .ik-template__amount,
  .ik-template__field input,
  .ik-template__field textarea {
    min-height: 7mm;
    padding: 1mm;
    border-color: #777;
    background: #fff;
    color: #000;
  }

  .ik-template__item,
  .ik-template__field,
  .ik-template__row--head {
    font-size: 8.5pt;
  }

  .ik-template__notes textarea {
    min-height: 25mm;
  }

  .ik-template-table-wrap {
    overflow: visible;
  }

  .ik-template-table {
    display: table;
    width: 100%;
    table-layout: fixed;
    font-size: 7pt;
  }

  .ik-template-table colgroup {
    display: table-column-group;
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }

  .ik-template-table thead {
    display: table-header-group;
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }

  .ik-template-table tbody {
    display: table-row-group;
  }

  .ik-template-table tr {
    display: table-row;
    width: auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    break-inside: avoid;
  }

  .ik-template-table th,
  .ik-template-table td {
    display: table-cell;
    width: auto;
    padding: 0.7mm;
    border: 0.25mm solid #777;
    vertical-align: middle;
  }

  .ik-template-table td::before {
    display: none;
  }

  .ik-template-table th {
    background: #fff;
    color: #000;
    font-size: 7pt;
  }

  .ik-template-table td .ik-template__amount {
    min-height: 5.5mm;
    padding: 0.5mm;
    border-color: #777;
    background: #fff;
    color: #000;
    font-size: 7pt;
  }

  .ik-template-section--wide {
    margin-bottom: 3mm;
    padding: 2mm;
  }
}
