.monthly-close-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 20px;
  margin-bottom: 18px;
}

.monthly-close-heading h2 {
  margin: 8px 0 6px;
  font-size: clamp(22px, 2.3vw, 32px);
  line-height: 1.1;
}

.monthly-close-heading p,
.monthly-close-history p,
.monthly-client-reconciliation p {
  margin: 0;
  color: var(--muted);
  max-width: 760px;
}

.monthly-close-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.monthly-close-actions button:disabled,
.monthly-manual-checks > button:disabled {
  cursor: not-allowed;
  opacity: .48;
  box-shadow: none;
}

.monthly-close-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.monthly-close-status.forecast { background: #eef2ff; color: #4338ca; }
.monthly-close-status.draft { background: #fff7ed; color: #c2410c; }
.monthly-close-status.closed { background: #ecfdf5; color: #047857; }

.monthly-close-timeline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr) 36px minmax(0, 1fr);
  gap: 1px;
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--line);
}

.monthly-close-timeline > div {
  position: relative;
  min-height: 88px;
  padding: 16px 18px;
  background: var(--white);
}

.monthly-close-timeline > i {
  display: grid;
  place-items: center;
  background: var(--white);
  color: #a0a8b5;
  font-style: normal;
  font-size: 18px;
}

.monthly-close-timeline span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.monthly-close-timeline strong { display: block; font-size: 14px; }
.monthly-close-timeline small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.35; }

.monthly-close-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.monthly-close-metrics > article,
.client-comparison > div,
.monthly-close-confirm > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
}

.monthly-close-metrics span,
.client-comparison span,
.monthly-cash-guard span,
.monthly-calculation span,
.monthly-owner-payouts span,
.monthly-close-confirm span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.monthly-close-metrics strong,
.client-comparison strong,
.monthly-cash-guard strong,
.monthly-close-confirm strong { font-size: 17px; }
.monthly-close-metrics small { display: block; margin-top: 4px; color: var(--muted); }

.monthly-close-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.monthly-close-grid .panel,
.monthly-client-reconciliation,
.monthly-owner-payouts,
.monthly-close-history { margin: 0; }

.monthly-auto-checks,
.monthly-manual-checks,
.monthly-calculation,
.monthly-owner-payouts {
  display: grid;
  gap: 8px;
}

.monthly-auto-checks,
.monthly-manual-checks { padding: 14px; }

.monthly-auto-checks > div,
.monthly-manual-checks > button,
.monthly-calculation > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.monthly-auto-checks > div::after {
  content: 'Do sprawdzenia';
  flex: 0 0 auto;
  color: #b45309;
  font-size: 11px;
  font-weight: 800;
}

.monthly-auto-checks > div.ready::after { content: 'Gotowe'; color: #047857; }
.monthly-manual-checks > button {
  width: 100%;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.monthly-manual-checks > button > span {
  display: grid;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: #fff;
  font-weight: 800;
}
.monthly-manual-checks > button.checked { border-color: #a7f3d0; background: #f0fdf4; }
.monthly-manual-checks > button.checked > span { border-color: #059669; background: #059669; }
.monthly-manual-checks strong,
.monthly-auto-checks strong { display: block; font-size: 12px; }
.monthly-manual-checks small,
.monthly-auto-checks small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.35; }

.monthly-close-warning {
  margin: 0 14px 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 12px;
  line-height: 1.45;
}

.monthly-calculation { margin: 14px; }
.monthly-calculation > div.total { background: #111827; color: #fff; }
.monthly-calculation > div.total span { color: #d1d5db; }
.monthly-calculation > div.result { background: #ecfdf5; border-color: #a7f3d0; }

.client-match {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 800;
}
.client-match.good { background: #ecfdf5; color: #047857; }
.client-match.warning { background: #fff7ed; color: #c2410c; }

.client-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 14px 10px;
}

.monthly-client-invoices { display: grid; gap: 7px; margin: 0 14px 14px; }
.monthly-client-invoice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.monthly-client-invoice button { padding: 0; border: 0; background: none; color: var(--ink); font-weight: 800; text-align: left; }
.monthly-client-invoice small { display: block; margin-top: 3px; color: var(--muted); }
.monthly-client-invoice span { min-width: 64px; padding: 4px 7px; border-radius: 999px; font-size: 10px; font-weight: 800; text-align: center; }
.monthly-client-invoice span.paid { background: #ecfdf5; color: #047857; }
.monthly-client-invoice span.waiting { background: #eff6ff; color: #1d4ed8; }

.monthly-close-suggestions {
  display: grid;
  gap: 7px;
  margin: 12px 14px 14px;
  padding: 12px;
  border-radius: 11px;
  background: #fffbeb;
}
.monthly-close-suggestions > span { color: #92400e; font-size: 12px; }
.monthly-close-suggestions > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; }
.monthly-close-suggestions > div small { color: var(--muted); }
.monthly-close-suggestions > div .secondary { grid-column: 2; grid-row: 1 / span 2; }

.monthly-owner-payouts {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
}
.monthly-owner-payouts > article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.monthly-owner-payouts strong { display: block; margin: 4px 0; font-size: 20px; }
.monthly-owner-payouts small { color: var(--muted); line-height: 1.4; }
.monthly-owner-payouts .retained { background: #f8fafc; }

.monthly-close-history tbody tr { cursor: pointer; }
.monthly-close-history tbody tr:hover { background: #f8f7ff; }
.monthly-close-confirm { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.monthly-close-confirm small { grid-column: 1 / -1; color: var(--muted); line-height: 1.45; }

@media (max-width: 980px) {
  .monthly-close-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .monthly-close-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .monthly-close-heading { display: block; }
  .monthly-close-actions { justify-content: flex-start; margin-top: 12px; }
  .monthly-close-timeline,
  .monthly-close-metrics,
  .client-comparison,
  .monthly-owner-payouts,
  .monthly-close-confirm { grid-template-columns: 1fr; }
  .monthly-close-timeline > i { display: none; }
  .monthly-close-timeline { gap: 1px; }
  .monthly-close-timeline > div { min-height: auto; }
  .monthly-client-invoice { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .monthly-client-invoice span { grid-column: 1 / -1; justify-self: start; }
  .monthly-close-suggestions > div { grid-template-columns: 1fr; }
  .monthly-close-suggestions > div .secondary { grid-column: auto; grid-row: auto; justify-self: start; }
}
