/**
 * ==============================================================================
 * Reconciliation Statement - Report Design
 * File: css/app-reconciliation.css
 * Scope: everything is scoped under .rcs-page so it never leaks to other pages.
 * Visual language: matches the Enterprise Table system (Fund Adjustment) -
 *   teal (#0f766e) + dark slate, Inter, compact uppercase headers.
 * Features:
 *   - Mobile: real horizontal scroll inside the table box (contain: inline-size
 *     stops the wide table from stretching the card), sticky SL + Chart of
 *     Accounts columns, swipe hint.
 *   - Print: A4 portrait, 5mm margin (named page), dense 7.5pt table,
 *     repeating table header, rows never split across pages.
 * ==============================================================================
 */

.rcs-page {
  --rcs-teal: var(--aet-teal, #0f766e);
  --rcs-teal-dark: var(--aet-teal-hover, #115e59);
  --rcs-teal-light: var(--aet-teal-light, #f0fdfa);
  --rcs-teal-border: var(--aet-teal-border, #ccfbf1);
  --rcs-dark: var(--aet-dark, #0f172a);
  --rcs-text: var(--aet-text, #1e293b);
  --rcs-muted: var(--aet-text-muted, #64748b);
  --rcs-secondary: var(--aet-text-secondary, #475569);
  --rcs-border: var(--aet-border, #cbd5e1);
  --rcs-border-light: var(--aet-border-light, #e2e8f0);
  --rcs-border-strong: var(--aet-border-strong, #94a3b8);
  --rcs-bg-soft: var(--aet-bg-soft, #f8fafc);
  --rcs-row-alt: var(--aet-bg-row-alt, #fafbfc);
  --rcs-row-hover: var(--aet-bg-row-hover, #f1f5f9);
  --rcs-radius: var(--aet-radius, 6px);
  --rcs-font: var(--aet-font, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif);

  font-family: var(--rcs-font);
  color: var(--rcs-text);
  min-width: 0;
  max-width: 100%;
}

/* Never let any wrapper grow to the table's width - the table scrolls instead */
.rcs-page .card,
.rcs-page .card-body,
.rcs-page .rcs-wrapper,
.rcs-page .rcs-report,
.rcs-page .rcs-block {
  min-width: 0;
  max-width: 100%;
}

/* ------------------------------------------------------------------ */
/* 1. CARD HEADER                                                      */
/* ------------------------------------------------------------------ */
.rcs-page .card-header .card-title i {
  color: var(--rcs-teal);
  margin-right: 6px;
}

.rcs-page .card-tools {
  gap: 6px;
}

.rcs-page .rcs-print-btn {
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* 2. FILTER TOOLBAR                                                   */
/* ------------------------------------------------------------------ */
.rcs-toolbar {
  background: #ffffff;
  border-bottom: 1px solid var(--rcs-border);
  padding: 10px 14px !important;
}

/* One compact inline row on desktop (label + select side by side, like Fund Adjustment) */
.rcs-page .rcs-filter {
  align-items: center !important;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  gap: 16px !important;
  margin: 0 !important;
  width: 100% !important;
}

.rcs-page .rcs-field {
  align-items: center !important;
  display: flex !important;
  flex: 1 1 0 !important;
  flex-direction: row !important;
  gap: 8px !important;
  margin: 0 !important;
  max-width: 460px !important;
  min-width: 0 !important;
  width: auto !important;
}

.rcs-page .rcs-select {
  flex: 1 1 auto;
  min-width: 0;
}

.rcs-page .rcs-filter .select2-container .select2-selection--single {
  height: 34px !important;
  min-height: 34px !important;
}

.rcs-page .rcs-filter .select2-container .select2-selection__rendered {
  font-size: 13px !important;
  line-height: 32px !important;
}

.rcs-page .rcs-filter .select2-container .select2-selection__arrow {
  height: 32px !important;
}

.rcs-field-label {
  color: var(--rcs-secondary);
  display: inline-flex !important;
  align-items: center;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  margin: 0 !important;
  text-transform: uppercase;
  white-space: nowrap;
}

.rcs-field-label i {
  color: var(--rcs-teal);
  margin-right: 4px;
}

.rcs-field-label .req {
  color: #dc2626;
}

.rcs-filter .select2-container {
  width: 100% !important;
}

.rcs-page .rcs-filter .rcs-search-btn {
  flex: 0 0 auto !important;
  height: 34px !important;
  justify-content: center;
  margin: 0 !important;
  min-width: 110px;
  padding: 0 16px !important;
  width: auto !important;
}

/* Tablet: stack label above select, fields share the row */
@media (max-width: 1199.98px) {
  .rcs-page .rcs-filter {
    align-items: flex-end !important;
    flex-wrap: wrap !important;
    gap: 10px 12px !important;
  }

  .rcs-page .rcs-field {
    align-items: stretch !important;
    flex: 1 1 240px !important;
    flex-direction: column !important;
    gap: 4px !important;
    max-width: none !important;
  }
}

/* ------------------------------------------------------------------ */
/* 3. REPORT DOCUMENT                                                  */
/* ------------------------------------------------------------------ */
.rcs-report {
  padding: 16px;
}

.rcs-doc-head {
  border-bottom: 2px solid var(--rcs-dark);
  margin-bottom: 14px;
  padding-bottom: 12px;
  text-align: center;
}

.rcs-company {
  color: var(--rcs-dark);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2px;
  line-height: 1.25;
  margin: 0;
}

.rcs-project {
  color: var(--rcs-secondary);
  font-size: 14px;
  font-weight: 600;
  margin: 2px 0 0;
}

.rcs-project b {
  color: var(--rcs-dark);
}

.rcs-doc-title {
  background: var(--rcs-teal-light);
  border: 1px solid var(--rcs-teal-border);
  border-radius: 999px;
  color: var(--rcs-teal-dark);
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.2px;
  margin: 8px 0 0;
  padding: 4px 14px;
  text-transform: uppercase;
}

.rcs-meta {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 12px;
  text-align: left;
}

.rcs-meta-item {
  background: var(--rcs-bg-soft);
  border: 1px solid var(--rcs-border-light);
  border-left: 3px solid var(--rcs-teal);
  border-radius: var(--rcs-radius);
  min-width: 0;
  padding: 6px 10px;
}

.rcs-meta-label {
  color: var(--rcs-muted);
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.rcs-meta-value {
  color: var(--rcs-dark);
  display: block;
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Section blocks */
.rcs-block {
  margin-top: 18px;
}

.rcs-block:first-of-type {
  margin-top: 0;
}

.rcs-block-head {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.rcs-block-title {
  align-items: center;
  color: var(--rcs-dark);
  display: flex;
  font-size: 14px;
  font-weight: 800;
  gap: 8px;
  letter-spacing: 0.2px;
  margin: 0;
}

.rcs-block-title::before {
  background: var(--rcs-teal);
  border-radius: 2px;
  content: "";
  display: inline-block;
  height: 16px;
  width: 4px;
}

.rcs-swipe-hint {
  color: var(--rcs-muted);
  display: none;
  font-size: 11px;
  white-space: nowrap;
}

/* Scroll box: contain:inline-size keeps the wide table from widening the card */
.rcs-scroll {
  background: #ffffff;
  border: 1px solid var(--rcs-border);
  border-radius: var(--rcs-radius);
  contain: inline-size;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-color: rgba(148, 163, 184, 0.6) transparent;
  scrollbar-width: thin;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

.rcs-scroll::-webkit-scrollbar {
  height: 8px;
}

.rcs-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.6);
  border-radius: 999px;
}

/* ------------------------------------------------------------------ */
/* 4. TABLES                                                           */
/* ------------------------------------------------------------------ */
.rcs-table {
  border-collapse: separate;
  border-spacing: 0;
  color: var(--rcs-text);
  font-family: var(--rcs-font);
  font-size: 12px;
  line-height: 1.4;
  margin: 0;
  table-layout: fixed;
  width: 100%;
}

.rcs-table th,
.rcs-table td {
  border-bottom: 1px solid var(--rcs-border-light);
  border-right: 1px solid var(--rcs-border-light);
  padding: 6px 8px;
  vertical-align: top;
}

.rcs-table tr > :last-child {
  border-right: none;
}

.rcs-table thead th {
  background: var(--rcs-bg-soft);
  border-bottom: 1px solid var(--rcs-border-strong);
  color: var(--rcs-secondary);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.35px;
  line-height: 1.25;
  text-align: center;
  text-transform: uppercase;
  vertical-align: middle;
}

.rcs-table tbody tr {
  background: #ffffff;
}

.rcs-table tbody tr:nth-child(even) {
  background: var(--rcs-row-alt);
}

.rcs-table tbody tr:hover {
  background: var(--rcs-row-hover);
}

.rcs-table .num,
.rcs-main td:nth-child(n+4) {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.rcs-main tbody td:nth-child(1),
.rcs-closing tbody td:nth-child(1) {
  color: var(--rcs-muted);
  text-align: center;
  white-space: nowrap;
}

.rcs-main tbody td:nth-child(2) {
  color: var(--rcs-dark);
  font-weight: 500;
}

.rcs-main tbody td:nth-child(3) {
  color: var(--rcs-secondary);
  overflow-wrap: break-word;
}

.rcs-main td b,
.rcs-main td strong {
  color: var(--rcs-dark);
  font-weight: 700;
}

/* Main statement column widths (screen) */
.rcs-main {
  min-width: 1000px;
}

.rcs-main col.c-sl { width: 52px; }
.rcs-main col.c-coa { width: 180px; }
.rcs-main col.c-detail { width: auto; }
.rcs-main col.c-amt { width: 108px; }

/* Category row */
.rcs-table tbody tr.rcs-cat,
.rcs-table tbody tr.rcs-cat:hover {
  background: var(--rcs-teal-light);
}

.rcs-table tr.rcs-cat td {
  border-bottom-color: var(--rcs-teal-border);
  color: var(--rcs-teal-dark);
  font-weight: 800;
  text-align: left;
}

.rcs-table tr.rcs-cat td:first-child {
  box-shadow: inset 3px 0 0 var(--rcs-teal);
  color: var(--rcs-teal-dark);
  text-align: center;
}

/* Opening balance row */
.rcs-table tbody tr.rcs-open,
.rcs-table tbody tr.rcs-open:hover {
  background: #fffbeb;
}

.rcs-table tr.rcs-open td {
  color: #92400e;
  font-weight: 600;
  text-align: left;
}

.rcs-table tr.rcs-open td.num {
  text-align: right;
}

/* Totals */
.rcs-table tfoot td {
  background: var(--rcs-bg-soft);
  border-bottom: 2px solid var(--rcs-border-strong);
  border-top: 2px solid var(--rcs-border-strong);
  color: var(--rcs-dark);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.rcs-table tfoot tr.rcs-words td {
  border-top: none;
  font-weight: 500;
  text-align: left;
  white-space: normal;
}

/* Fund received summary */
.rcs-summary {
  min-width: 420px;
}

.rcs-summary col.c-label { width: auto; }
.rcs-summary col.c-amount { width: 170px; }

.rcs-summary td:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.rcs-summary .summary-label-right {
  text-align: right;
}

.rcs-summary tr.summary-bold-row td {
  background: var(--rcs-bg-soft);
  color: var(--rcs-dark);
  font-weight: 800;
}

.rcs-summary tbody tr.summary-final-row,
.rcs-summary tbody tr.summary-final-row:hover {
  background: var(--rcs-teal-light);
}

.rcs-summary tr.summary-final-row td {
  background: var(--rcs-teal-light);
  border-bottom: 2px solid var(--rcs-teal);
  border-top: 2px solid var(--rcs-teal);
  color: var(--rcs-teal-dark);
  font-size: 13px;
  font-weight: 800;
}

/* Summary of closing balance (editable) */
.rcs-closing {
  min-width: 760px;
}

.rcs-closing col.c-sl { width: 60px; }
.rcs-closing col.c-coa { width: 200px; }
.rcs-closing col.c-detail { width: auto; }
.rcs-closing col.c-amt { width: 150px; }
.rcs-closing col.c-edit { width: 84px; }

.rcs-closing td:nth-child(4) {
  text-align: right;
}

.rcs-closing td:nth-child(5) {
  text-align: center;
}

.rcs-closing td {
  vertical-align: middle;
}

.rcs-closing input.form-control {
  border: 1px solid var(--rcs-border);
  border-radius: 4px;
  font-size: 12px;
  height: 30px;
  margin: 0;
  padding: 4px 8px;
  width: 100%;
}

.rcs-closing input.form-control:focus {
  border-color: var(--rcs-teal);
  box-shadow: 0 0 0 3px var(--aet-teal-focus, rgba(15, 118, 110, 0.2));
  outline: none;
}

.rcs-closing .closing-balance-amount {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.rcs-closing .aet-btn {
  justify-content: center;
  padding: 4px 10px;
}

.rcs-save-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.rcs-page .print-only {
  display: none;
}

/* Empty state */
.rcs-empty {
  color: var(--rcs-muted);
  padding: 48px 16px;
  text-align: center;
}

.rcs-empty i {
  color: var(--rcs-border-strong);
  display: block;
  font-size: 32px;
  margin-bottom: 10px;
}

.rcs-empty p {
  font-size: 13px;
  margin: 0;
}

/* ------------------------------------------------------------------ */
/* 5. TABLET & MOBILE                                                  */
/* ------------------------------------------------------------------ */
@media (max-width: 991.98px) {
  .rcs-report {
    padding: 12px 10px;
  }

  .rcs-swipe-hint {
    display: inline;
  }

  /* Sticky SL + Chart of Accounts while scrolling sideways */
  .rcs-main {
    min-width: 900px;
  }

  .rcs-main col.c-sl { width: 40px; }
  .rcs-main col.c-coa { width: 130px; }
  .rcs-main col.c-amt { width: 96px; }

  .rcs-main th:nth-child(1),
  .rcs-main td:nth-child(1),
  .rcs-main th:nth-child(2),
  .rcs-main tbody tr:not(.rcs-open) td:nth-child(2) {
    background: inherit;
    position: sticky;
    z-index: 2;
  }

  .rcs-main th:nth-child(1),
  .rcs-main td:nth-child(1) {
    left: 0;
  }

  .rcs-main th:nth-child(2),
  .rcs-main tbody tr:not(.rcs-open) td:nth-child(2) {
    box-shadow: 3px 0 4px -2px rgba(15, 23, 42, 0.18);
    left: 40px;
  }

  .rcs-main thead th:nth-child(1),
  .rcs-main thead th:nth-child(2) {
    background: var(--rcs-bg-soft);
    z-index: 3;
  }

  .rcs-main tbody tr,
  .rcs-main tfoot tr {
    background: #ffffff;
  }

  .rcs-main tfoot td:first-child {
    position: static;
  }
}

@media (max-width: 767.98px) {
  .rcs-toolbar {
    padding: 10px !important;
  }

  .rcs-page .rcs-field {
    flex: 1 1 100% !important;
  }

  .rcs-page .rcs-filter .rcs-search-btn {
    width: 100% !important;
  }

  .rcs-page .card-tools {
    margin-left: 0 !important;
    margin-top: 6px;
    width: 100%;
  }

  .rcs-page .rcs-print-btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  /* Edge-to-edge report on phones: no side gutter, tables touch the card edge */
  .rcs-page .rcs-report {
    padding: 8px 0 !important;
  }

  .rcs-page .rcs-doc-head,
  .rcs-page .rcs-block-head,
  .rcs-page .rcs-save-bar {
    padding-left: 6px;
    padding-right: 6px;
  }

  .rcs-page .rcs-block {
    margin-top: 12px;
  }

  .rcs-page .rcs-scroll {
    border-left: 0;
    border-radius: 0;
    border-right: 0;
  }

  .rcs-page .rcs-table th,
  .rcs-page .rcs-table td {
    padding: 5px 5px;
  }

  .rcs-company {
    font-size: 16px;
  }

  .rcs-project {
    font-size: 13px;
  }

  .rcs-meta {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .rcs-table {
    font-size: 11.5px;
  }

  .rcs-table th,
  .rcs-table td {
    padding: 5px 6px;
  }

  .rcs-summary {
    min-width: 0;
  }

  .rcs-summary col.c-amount {
    width: 118px;
  }
}

/* ------------------------------------------------------------------ */
/* 6. PRINT - A4 portrait, minimum margin                              */
/* ------------------------------------------------------------------ */
@media print {
  @page rcs-a4 {
    size: A4 portrait;
    margin: 5mm;
  }

  body:has(.rcs-page) {
    page: rcs-a4;
  }

  html,
  body {
    background: #ffffff !important;
  }

  .rcs-page,
  .rcs-page * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  .rcs-page {
    color: #000000 !important;
    font-family: Calibri, "Segoe UI", Arial, sans-serif !important;
  }

  .rcs-page .card-header,
  .rcs-page .rcs-toolbar,
  .rcs-page .rcs-swipe-hint,
  .rcs-page .rcs-save-bar,
  .rcs-page .d-print-none,
  .rcs-page input,
  .rcs-page button {
    display: none !important;
  }

  .rcs-page .print-only {
    display: inline !important;
  }

  .rcs-page .card,
  .rcs-page .card-body,
  .rcs-page .rcs-wrapper,
  .rcs-page .rcs-report {
    background: #ffffff !important;
    border: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    overflow: visible !important;
    padding: 0 !important;
    width: 100% !important;
  }

  /* Compact document header */
  .rcs-doc-head {
    border-bottom: 1.2pt solid #000 !important;
    margin: 0 0 4px !important;
    padding: 0 0 3px !important;
  }

  .rcs-company {
    color: #000 !important;
    font-size: 13pt !important;
    line-height: 1.15 !important;
  }

  .rcs-project {
    color: #000 !important;
    font-size: 9.5pt !important;
    margin: 0 !important;
  }

  .rcs-doc-title {
    background: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    color: #000 !important;
    font-size: 10.5pt !important;
    letter-spacing: 0.6px !important;
    margin: 1px 0 0 !important;
    padding: 0 !important;
    text-decoration: underline;
  }

  .rcs-meta {
    display: flex !important;
    gap: 0 !important;
    justify-content: space-between !important;
    margin-top: 3px !important;
  }

  .rcs-meta-item {
    background: none !important;
    border: 0 !important;
    padding: 0 !important;
  }

  .rcs-meta-item + .rcs-meta-item {
    text-align: right;
  }

  .rcs-meta-item:nth-child(2) {
    text-align: center;
  }

  .rcs-meta-label,
  .rcs-meta-value {
    color: #000 !important;
    display: inline !important;
    font-size: 8.5pt !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
  }

  .rcs-meta-label {
    font-weight: 700 !important;
  }

  .rcs-meta-label::after {
    content: " :";
  }

  /* Sections */
  .rcs-block {
    margin-top: 6px !important;
  }

  .rcs-block:first-of-type {
    margin-top: 0 !important;
  }

  .rcs-block-head {
    margin: 0 0 2px !important;
  }

  .rcs-block-title {
    color: #000 !important;
    font-size: 9.5pt !important;
  }

  .rcs-block-title::before {
    background: #000 !important;
    height: 9pt !important;
    width: 2.5pt !important;
  }

  .rcs-summary-block,
  .rcs-closing-block {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .rcs-scroll {
    border: 0 !important;
    border-radius: 0 !important;
    contain: none !important;
    overflow: visible !important;
  }

  /* Dense tables */
  .rcs-table {
    border: 0.75pt solid #000 !important;
    border-collapse: collapse !important;
    font-size: 7.5pt !important;
    line-height: 1.2 !important;
    min-width: 0 !important;
    table-layout: fixed !important;
    width: 100% !important;
  }

  .rcs-table th,
  .rcs-table td {
    border: 0.5pt solid #555 !important;
    color: #000 !important;
    padding: 1.5px 3px !important;
    position: static !important;
  }

  .rcs-table thead {
    display: table-header-group !important;
  }

  .rcs-table tfoot {
    display: table-row-group !important;
  }

  .rcs-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .rcs-table thead th {
    background: #e5e7eb !important;
    font-size: 6.8pt !important;
    font-weight: 800 !important;
    letter-spacing: 0 !important;
    padding: 2px 2px !important;
  }

  .rcs-table tbody tr,
  .rcs-table tbody tr:nth-child(even) {
    background: #ffffff !important;
  }

  .rcs-main td:nth-child(1),
  .rcs-closing td:nth-child(1),
  .rcs-main td:nth-child(3) {
    color: #000 !important;
  }

  .rcs-table tr.rcs-cat td {
    background: #eef2f5 !important;
    box-shadow: none !important;
    color: #000 !important;
  }

  .rcs-table tr.rcs-open td {
    background: #ffffff !important;
    color: #000 !important;
  }

  .rcs-table tfoot td,
  .rcs-summary tr.summary-bold-row td {
    background: #f1f5f9 !important;
    border-top: 1pt solid #000 !important;
    color: #000 !important;
  }

  .rcs-summary tr.summary-final-row td {
    background: #e5e7eb !important;
    border-bottom: 1pt solid #000 !important;
    border-top: 1pt solid #000 !important;
    color: #000 !important;
    font-size: 8pt !important;
  }

  .rcs-table tfoot tr.rcs-words td {
    background: #ffffff !important;
    border-top: 0.5pt solid #555 !important;
  }

  /* A4 column widths (printable width ~200mm) */
  .rcs-main col.c-sl { width: 4.5%; }
  .rcs-main col.c-coa { width: 14%; }
  .rcs-main col.c-detail { width: 33.5%; }
  .rcs-main col.c-amt { width: 8%; }

  .rcs-summary {
    font-size: 8pt !important;
  }

  .rcs-summary col.c-amount { width: 22%; }

  .rcs-closing col.c-sl { width: 7%; }
  .rcs-closing col.c-coa { width: 23%; }
  .rcs-closing col.c-detail { width: 52%; }
  .rcs-closing col.c-amt { width: 18%; }
  .rcs-closing col.c-edit { visibility: collapse; width: 0; }
}
