/* ================================
   Стиль для друку
   ================================ */
@media print {
  .table-acc {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    border: 1px solid #000;
    background: #fff;
  }

  .table-acc-header,
  .table-acc-row.transaction {
    display: table-row;
  }

  .table-acc-header div,
  .table-acc-row.transaction div {
    display: table-cell;
    border: 1px solid #000;
    padding: 4px;
    vertical-align: top;
    font-size: 11px;
    color: #000;
    background: #fff;
    white-space: normal;
    overflow-wrap: break-word;
  }

  /* Приховуємо непотрібні колонки */
  .table-acc-header div:nth-child(1),
  .table-acc-row.transaction div:nth-child(1),   /* № */
  .table-acc-header div:nth-child(2),
  .table-acc-row.transaction div:nth-child(2),   /* Номер операції */
  .table-acc-header div:nth-child(9),
  .table-acc-row.transaction div:nth-child(9),   /* ЄДРПОУ */
  .table-acc-header div:nth-child(10),
  .table-acc-row.transaction div:nth-child(10) { /* IBAN */
    display: none;
  }

  /* Єдині ширини */
  .table-acc-header div:nth-child(3),
  .table-acc-row.transaction div:nth-child(3) { width: 80px; text-align: center; }   /* Дата */
  .table-acc-header div:nth-child(4),
  .table-acc-row.transaction div:nth-child(4) { width: 80px; text-align: right; }    /* Прихід */
  .table-acc-header div:nth-child(5),
  .table-acc-row.transaction div:nth-child(5) { width: 80px; text-align: right; }    /* Розхід */
  .table-acc-header div:nth-child(6),
  .table-acc-row.transaction div:nth-child(6) { width: 50px; text-align: center; }   /* Валюта */
  .table-acc-header div:nth-child(7),
  .table-acc-row.transaction div:nth-child(7) { width: auto; text-align: left; }     /* Призначення */
  .table-acc-header div:nth-child(8),
  .table-acc-row.transaction div:nth-child(8) { width: 200px; text-align: left; }    /* Контрагент */

  /* Підвал */
  .summary {
    display: table-row;
    font-weight: bold;
    border-top: 2px solid #000;
    background: #f2f2f2;
  }
  .summary div {
    display: table-cell;
    padding: 6px;
    text-align: right;
  }
}

/* ================================
   Контейнер всього звіту
   ================================ */
.table-acc {
  width: 100%;
  margin: 0 auto;
  background: #f9fbff;
  border: 1px solid #0078d7;
  border-radius: 6px;
  font-family: "Segoe UI", Arial, sans-serif;
  box-sizing: border-box;
}

/* Заголовок рахунку */
.table-acc-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.account-info-left,
.account-info-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.account-info-left { text-align: left; }
.account-info-left a { margin-left: auto; }
.account-info-right { justify-content: flex-end; text-align: right; }

.account-name { font-size: 20px; }
.account-iban,
.account-edrpou { font-size: 16px; }

.balance-in,
.balance-out {
  display: flex;
#  flex: 1 1 100%;     /* займає всю ширину */
  flex: 0 0 auto; /* не займають всю ширину самі */
  align-items: center;
  justify-content: space-between; /* текст ліворуч, іконка праворуч */
  gap: 8px;
  font-size: 14px;
}
.currency-icon { width: 30px; height: 16px; }

/* Стрілка */
.arrow-up {
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 15px solid #000;
  display: inline-block;
}

/* ================================
   Сітка таблиці (екран)
   ================================ */
.table-acc-header,
.table-acc-row.transaction {
  display: grid;
  grid-template-columns:
    40px   /* № */
    90px   /* Номер операції */
    76px   /* Дата */
    90px   /* Прихід */
    90px   /* Розхід */
    50px   /* Валюта */
    1fr    /* Призначення */
    220px  /* Контрагент */
    86px   /* ЄДРПОУ */
    210px; /* IBAN */
  font-size: 12px;
}

/* Шапка */
.table-acc-header {
  background: #e6f2ff;
  border-bottom: 2px solid #0078d7;
  font-weight: 600;
  color: #2c3e50;
  align-items: center;
  height: 40px;
}
.table-acc-header div {
  text-align: center;
  border-right: 1px solid #d9e6f2;
  padding: 0;
}
.table-acc-header div:last-child { border-right: none; }

/* Рядки */
.table-acc-row.transaction {
  border-bottom: 1px solid #eee;
  background: #fff;
}
.table-acc-row.transaction div {
  border-right: 1px solid #f0f0f0;
  padding: 6px 8px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.table-acc-row.transaction div:last-child { border-right: none; }
.table-acc-row.transaction:hover { background: #f7fbff; }

/* ================================
   Кнопки
   ================================ */
.btn-plat {
  font-family: "Segoe UI", Arial, sans-serif;
  width: 100%;
  height: 20px;
  font-size: 9px;
  font-weight: 500;
  padding: 2px 4px;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid #005a9e;
  background: #0078d7;
  color: #fff;
  transition: background 0.2s ease, transform 0.1s ease;
  display: inline-block;
}
.btn-plat:hover { background: #005a9e; }
.btn-plat:active { transform: scale(0.96); }

.btn-open {
  margin: 2px 4px;
  min-width: 50px;
  text-align: center;
}

/* ================================
   Колонки (екран)
   ================================ */
.cell-num { text-align: center; font-size: 10px; }
.cell-ntrans { text-align: center; }
.cell-date { text-align: center; }
.cell-cred { text-align: right; font-weight: 600; color: green; }
.cell-debt { text-align: right; font-weight: 600; color: red; }
.cell-curr { text-align: center; font-weight: 600; }
.cell-osnd { text-align: left; padding-left: 6px; font-style: italic; }
.cell-cntr { text-align: left; font-weight: 600; }
.cell-edrpou { text-align: left; }
.cell-acc { text-align: left; white-space: nowrap; font-family: monospace; }

/* Підвал */
.summary {
  display: flex;
  justify-content: flex-end;
  gap: 40px;
  padding: 10px;
  background: #eef6ff;
  border-top: 2px solid #0078d7;
  font-weight: 600;
  font-size: 12px;
}
.summary .balance-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.summary b { color: #2c3e50; font-size: 14px; }

/* ================================
   Адаптація
   ================================ */

/* Планшети */
@media (max-width: 1024px) {
  .table-acc { font-size: 11px; padding: 8px; }
  .account-name { font-size: 16px; }
  .account-iban, .account-edrpou { font-size: 13px; }
  .balance-in, .balance-out { font-size: 12px; }
  .currency-icon { width: 22px; height: 12px; }
}

/* Смартфони */
@media (max-width: 768px) {
  .table-acc {
    font-size: 10px;
    padding: 6px;
  }
  .table-acc-head {
    flex-direction: column;
    gap: 4px;
  }
  .account-info-left,
  .account-info-right {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .account-info-left a {
    margin-left: 0;
    align-self: flex-end; /* стрілка лишається справа */
  }
  .account-name { font-size: 14px; }
  .account-iban,
  .account-edrpou { font-size: 12px; }
  .balance-in,
  .balance-out {
    font-size: 11px;
    margin-left: 0;
  }
  .currency-icon { width: 20px; height: 12px; }
  .summary {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    font-size: 11px;
  }
}

/* Дуже маленькі екрани */
@media (max-width: 480px) {
  .table-acc {
    font-size: 9px;
    padding: 4px;
    border: none;
    border-radius: 0;
  }

  /* Таблиця → список */
  .table-acc-header,
  .table-acc-row.transaction {
    display: block;
  }
  .table-acc-header div,
  .table-acc-row.transaction div {
    display: flex;
    justify-content: space-between;
    padding: 4px 6px;
    border: none;
    border-bottom: 1px solid #ddd;
    width: 100%;
    text-align: left;
    font-size: 9px;
  }

  .table-acc-head {
    flex-direction: column;
    gap: 4px;
  }
  .account-info-left,
  .account-info-right {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .account-name { font-size: 12px; }
  .account-iban,
  .account-edrpou { font-size: 11px; }
  .balance-in,
  .balance-out { font-size: 10px; }
  .currency-icon { width: 16px; height: 10px; }
  .arrow-up {
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 10px solid #000;
  }
  .summary {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    font-size: 10px;
  }
}
