:root {
  --bg: #0b1220;
  --text: #e9eefc;
  --muted: #c3b6e8;
  --accent: #ce79bc;
  --border: rgba(255, 255, 255, 0.14);
  --panel: rgba(255, 255, 255, 0.03);
  --panel2: rgba(255, 255, 255, 0.06);
  --edit-bg: rgba(214, 160, 0, 0.22);
  --edit-border: rgba(214, 160, 0, 0.50);
  --edit-focus: rgba(255, 208, 64, 0.95);
  --edit-glow: rgba(255, 200, 0, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  background: radial-gradient(1000px 600px at 20% 10%, #3b1642 0%, var(--bg) 60%);
  color: var(--text);
  line-height: 1.5;
}

.container {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
}

.muted {
  color: var(--muted);
}

/* =========================
   Header / nav
   ========================= */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  background: rgba(11, 18, 32, 0.65);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
}

.logo {
  text-decoration: none;
  color: var(--text);
  font-weight: 900;
  letter-spacing: 1px;
}

.menu {
  display: flex;
  gap: 14px;
  align-items: center;
}

.menu a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: 0.2s;
}

.menu a:hover {
  border-color: var(--border);
  background: var(--panel2);
}

.hamburger {
  display: none;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

/* =========================
   Language dropdown
   ========================= */
.lang-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.lang-btn {
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s;
  font: inherit;
}

.lang-btn:hover {
  border-color: var(--border);
  background: var(--panel2);
}

.lang-btn:focus {
  outline: none;
  border-color: var(--accent);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 180px;
  background: rgba(11, 18, 32, 0.92);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  display: none;
  z-index: 30;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.lang-dropdown.open {
  display: grid;
  gap: 4px;
}

.lang-option {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}

.lang-option:hover {
  background: var(--panel2);
  border-color: var(--border);
}

.lang-option.active {
  border-color: var(--accent);
  background: rgba(255, 79, 216, 0.12);
}

/* =========================
   Layout
   ========================= */
.hero {
  padding: 40px 0 20px;
}

.section {
  padding: 20px 0;
}

.card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
}

.companies-card {
  display: grid;
  gap: 16px;
}

.companies-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.companies-list {
  display: grid;
  gap: 16px;
}

.company-title {
  margin: 0;
}

.companies3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 16px;
}

.block {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
}

.block-head {
  padding: 10px 12px;
  font-weight: 800;
  background: var(--panel2);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.section-stack {
  display: grid;
  gap: 20px;
  margin-top: 28px;
}

.section-card {
  display: grid;
  gap: 16px;
}

.section-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-card-head h3 {
  margin: 0;
}

.expected-section-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.section-company-block {
  overflow: hidden;
}

.section-company-block--compact .block-head {
  border-bottom: 0;
}

.expected-company-head-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  width: 100%;
}

.expected-company-title {
  min-width: 0;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

.expected-company-head-wrap > .inline-section-add-btn {
  justify-self: end;
  flex: 0 0 auto;
}

.inline-section-add-btn {
  min-height: 0;
}

.expected-empty-body {
  min-height: 112px;
}

.section-company-block--compact .expected-company-head-wrap {
  min-height: 34px;
}

/* =========================
   Tables
   ========================= */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table td,
.data-table th {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.data-table .num {
  text-align: right;
  width: 140px;
}

.summary-table th {
  text-align: left;
}

.summary-table th.num {
  text-align: right;
}

.summary-table tfoot th {
  border-bottom: none;
}

.data-table th,
.data-table thead th,
.data-table td:first-child,
.data-table th:first-child {
  text-align: left;
}

.data-table thead th.num,
.data-table td.num,
.summary-table thead th.num,
.summary-table td.num,
.summary-table tfoot th.num {
  text-align: right;
}

/* =========================
   Inputs
   ========================= */
.cell-input,
.total-input,
.name-input,
.tax-custom-input {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  outline: none;
  transition: 0.2s;
}

.cell-input:focus,
.name-input:focus {
  border-color: var(--accent);
}

.inline-name-input {
  min-width: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  padding: 6px 10px;
}

.inline-name-input::placeholder {
  color: var(--text);
  opacity: 0.9;
}

.auto-field {
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  cursor: not-allowed;
}

.name-input:placeholder-shown,
.inline-name-input:placeholder-shown {
  background: var(--edit-bg);
  border-color: var(--edit-border);
}

.name-input:placeholder-shown:focus,
.inline-name-input:placeholder-shown:focus {
  border-color: var(--edit-focus);
  box-shadow: 0 0 0 3px var(--edit-glow);
}

.cell-input.needs-fill {
  background: var(--edit-bg);
  border-color: var(--edit-border);
  color: var(--text);
}

.cell-input.needs-fill:focus {
  border-color: var(--edit-focus);
  box-shadow: 0 0 0 3px var(--edit-glow);
}

/* =========================
   Totals
   ========================= */
.total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
}

.total-input {
  width: 140px;
  text-align: right;
  font-weight: 700;
}

.total-box {
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
  min-width: 0;
  box-shadow: none;
  text-align: right;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.35;
}

/* =========================
   Misc form blocks
   ========================= */
.field {
  display: grid;
  gap: 4px;
  padding: 8px 12px;
}

.field span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

/* =========================
   Footer
   ========================= */
.footer {
  padding: 40px 0;
  text-align: center;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* =========================
   Buttons
   ========================= */
.export-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  transition: 0.2s;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.22);
}

.btn:active {
  transform: translateY(1px);
}

.btn-ico {
  width: 18px;
  height: 18px;
  display: inline-flex;
}

.btn-ico svg {
  width: 18px;
  height: 18px;
  display: block;
  opacity: 0.9;
}

.table-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: 0.2s;
}

.table-add-btn:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.22);
}

.table-add-btn-ico {
  width: 14px;
  height: 14px;
  display: inline-flex;
  flex: 0 0 14px;
}

.table-add-btn-ico svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* =========================
   Section head
   ========================= */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 12px;
}

.section-title {
  margin: 0;
}

.section-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* =========================
   Currency / amount
   ========================= */
.currency-select {
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  padding: 7px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s;
  font: inherit;
  width: 72px;
  text-align: center;
}

.currency-select:hover {
  border-color: var(--border);
  background: var(--panel2);
}

.currency-select:focus {
  outline: none;
  border-color: var(--accent);
}

.currency-select option {
  background: rgba(11, 18, 32, 0.95);
  color: var(--text);
}

.amt-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.amt-input {
  flex: 1;
  min-width: 120px;
}

.amt-cur {
  width: 72px;
  padding: 7px 10px;
}

/* =========================
   Account name field + remove
   ========================= */
.acc-name-wrap {
  position: relative;
  width: 50%;
}

.acc-name-input {
  width: 100%;
  padding-right: 38px;
}

.acc-remove-btn {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 30px;
  padding: 0;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 0 11px 11px 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.acc-remove-btn:hover {
  color: rgba(255, 255, 255, 0.92);
}

.acc-remove-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.company-remove-btn,
.bank-remove-btn,
.bank-remove-spacer {
  width: 30px;
  height: 30px;
  justify-self: end;
}

.bank-remove-btn {
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.2s;
}

.bank-remove-btn:hover {
  color: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.20);
  background: rgba(255, 255, 255, 0.04);
}

.bank-remove-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* =========================
   Header rows aligned with input width
   ========================= */
.th-account-wrap,
.company-head-wrap,
.bank-head-left {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.th-account-wrap {
  width: 50%;
}

.company-head-wrap {
  width: calc(50% + var(--table-head-btn-width, 0px) + 10px - 31px);
}

.bank-head-left {
  width: calc(50% + var(--table-head-btn-width, 0px) + 10px - 31px);
}

.company-head-row-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 30px;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.company-head-spacer {
  display: block;
}

.th-account-wrap > .table-add-btn,
.company-head-wrap > .table-add-btn,
.bank-head-left > .table-add-btn {
  width: var(--table-head-btn-width, auto);
  justify-self: end;
  justify-content: center;
}

.th-account-wrap > span,
.company-head-wrap > span,
.bank-head-left > span,
.company-inline-input,
.bank-name-input,
.js-th-account-text {
  min-width: 0;
}

/* =========================
   Horizontal scroll wrapper
   ========================= */
.table-scroll {
  width: 100%;
}

/* =========================
   Bank sections inside one table
   ========================= */
.company-bank-table thead {
  display: none;
}

.bank-head-row td {
  padding: 0;
  background: rgba(255, 255, 255, 0.02);
}

.bank-head-row-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 30px;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.bank-amount-label {
  text-align: right;
  font-size: 14px;
  font-weight: 800;
}

.bank-subtotal-row td {
  background: rgba(255, 255, 255, 0.02);
  font-weight: 700;
}

.grand-total-row {
  border-top: 1px solid var(--border);
}

.grand-total-row .total-label {
  font-weight: 800;
}

/* =========================
   Expected / internal tables
   ========================= */
.expected-table {
  min-width: 860px;
}

.empty-action-row td {
  padding: 24px 12px;
  text-align: center;
}

.section-table-actions {
  display: flex;
  justify-content: flex-start;
  padding-top: 14px;
}

.expected-table input:not([type="checkbox"]) {
  min-width: 100px;
}

.internal-company-select {
  min-width: 190px;
  width: 100%;
}

.expected-table .expected-text-input {
  min-width: 170px;
}

.expected-table .js-expected-remaining {
  min-width: 120px;
  text-align: right;
}

.expected-section-grid .expected-table td,
.expected-section-grid .expected-table th {
  padding: 10px 8px;
}

.expected-section-grid .expected-table .num {
  width: 112px;
}

.expected-section-grid .expected-table input:not([type="checkbox"]) {
  min-width: 88px;
  padding: 7px 10px;
}

.expected-section-grid .expected-table .expected-text-input {
  min-width: 130px;
}

.expected-section-grid .expected-table .js-expected-remaining {
  min-width: 100px;
}

.expected-remove-col {
  width: 42px;
  text-align: center;
}

.expected-remove-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.2s;
}

.expected-remove-btn:hover {
  color: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.20);
  background: rgba(255, 255, 255, 0.04);
}

.expected-remove-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* =========================
   Responsive
   ========================= */
@media (max-width: 1200px) {
  .companies3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 850px) {
  .companies3,
  .expected-section-grid {
    grid-template-columns: 1fr;
  }

  .hamburger {
    display: block;
  }

  .menu {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 60px;
    right: 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 10px;
  }

  .menu.open {
    display: flex;
  }
}

@media (max-width: 650px) {
  .companies-card-head {
    flex-direction: column;
    align-items: stretch;
  }

  .companies-card-head > .table-add-btn {
    align-self: flex-end;
  }

  .export-actions .btn {
    flex: 1;
  }

  .section-head {
    align-items: stretch;
  }

  .section-actions {
    width: 100%;
  }

  .section-actions .btn {
    flex: 1;
  }

  .total-box {
    width: 100%;
    min-width: 0;
  }

  .acc-name-wrap,
  .th-account-wrap {
    width: 75%;
    min-width: 210px;
  }

  .company-head-wrap {
    width: calc(75% + var(--table-head-btn-width, 0px) + 10px - 31px);
    min-width: calc(210px + var(--table-head-btn-width, 0px) + 10px - 31px);
  }

  .bank-head-left {
    width: calc(75% + var(--table-head-btn-width, 0px) + 10px);
    min-width: calc(210px + var(--table-head-btn-width, 0px) + 10px - 31px);
  }

  .company-head-row-wrap {
    min-width: 480px;
  }

  .section-card,
  .section-card-head {
    min-width: 480px;
  }

  .acc-name-input {
    width: 100%;
  }

  .bank-name-input {
    width: 100%;
  }

  .bank-head-left {
    max-width: calc(75% + var(--table-head-btn-width, 0px) + 10px - 31px);
  }

  .table-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .table-scroll .data-table,
  .table-scroll .total-row {
    min-width: 480px;
  }

  .expected-table {
    min-width: 980px;
  }

  .bank-head-row-wrap {
    min-width: 480px;
  }
}

.footer a {
  color: #93c5fd;
  text-decoration: none;
}

.footer a:hover,
.footer a:focus-visible {
  color: #ffffff;
  text-decoration: underline;
}

/* tylko oczekiwane wpływy / wydatki */
#expected-inflows-wrapper .expected-table td.num,
#expected-outflows-wrapper .expected-table td.num,
#expected-inflows-wrapper .expected-table td.num input,
#expected-outflows-wrapper .expected-table td.num input {
  text-align: left;
}

#expected-inflows-wrapper .expected-col-counterparty,
#expected-outflows-wrapper .expected-col-counterparty {
  width: 240px;
}

#expected-inflows-wrapper .expected-col-invoice,
#expected-outflows-wrapper .expected-col-invoice {
  width: 160px;
}

#expected-inflows-wrapper .expected-col-num,
#expected-outflows-wrapper .expected-col-num {
  width: 112px;
}

#expected-inflows-wrapper .expected-col-remove,
#expected-outflows-wrapper .expected-col-remove {
  width: 42px;
}

/* internal invoicing */
.internal-master-toggle {
  padding: 10px 12px 0;
}

.internal-master-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}

.internal-master-checkbox {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 0;
  flex: 0 0 16px;
  display: inline-grid;
  place-content: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.internal-master-checkbox::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  transform: scale(0);
  transition: transform 0.12s ease-in-out;
}

.internal-master-checkbox:checked::before {
  transform: scale(1);
}

.internal-master-checkbox:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(206, 121, 188, 0.22);
}

.internal-include-checkbox {
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 0;
  display: inline-block;
  vertical-align: middle;
  accent-color: var(--accent);
  cursor: pointer;
}

.internal-billing-table th.internal-check-col,
.internal-billing-table td.internal-check-col {
  width: 42px;
  text-align: center;
  vertical-align: middle;
  line-height: 0;
}

#internal-billing-wrapper .internal-billing-table td.num,
#internal-billing-wrapper .internal-billing-table td.num input {
  text-align: left;
}

#internal-billing-wrapper .internal-col-check {
  width: 42px;
}

#internal-billing-wrapper .internal-col-company {
  width: 198px;
}

#internal-billing-wrapper .internal-col-invoice {
  width: 160px;
}

#internal-billing-wrapper .internal-col-num {
  width: 112px;
}

#internal-billing-wrapper .internal-col-remove {
  width: 42px;
}

#internal-billing-wrapper .internal-company-select {
  min-width: 150px;
}