:root {
  --bs-primary: #008bcc;
  --bs-primary-rgb: 0, 139, 204;
  --bs-link-color: #008bcc;
  --bs-link-hover-color: #006fa3;
}

.btn-primary {
  --bs-btn-bg: #008bcc;
  --bs-btn-border-color: #008bcc;
  --bs-btn-hover-bg: #006fa3;
  --bs-btn-hover-border-color: #006fa3;
  --bs-btn-active-bg: #005a85;
  --bs-btn-active-border-color: #005a85;
}

.bg-primary { background-color: #008bcc !important; }
.text-primary { color: #008bcc !important; }
.border-primary { border-color: #008bcc !important; }

/* AdminLTE 4 sidebar accent */
.app-sidebar.bg-primary,
.sidebar-dark-primary {
  background-color: #008bcc !important;
}

/* Numeric columns alignment */
.tnum {
  font-variant-numeric: tabular-nums;
}

/* Login screen */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #008bcc 0%, #005a85 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 420px;
  border: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.login-logo img {
  max-height: 192px;
  max-width: 100%;
}

/* Discrete attribution pinned to the bottom of the viewport so it never affects
   the card centering or sizing. Colour comes from the LoginPoweredByColor system
   setting (applied inline by the view); here we only handle positioning + size. */
.login-poweredby {
  position: absolute;
  bottom: 1rem;
  left: 0;
  right: 0;
  font-size: 0.78rem;
  pointer-events: none;
}

/* ============================================================
   Print stylesheet — clean rendering for paper / PDF export.
   We hide the navigation chrome and the in-page toolbars so the
   printed page focuses on the report body. The active mode (data-mode
   on the table) is respected — what the user is currently viewing on
   screen is what gets printed.
   ============================================================ */
@media print {
  /* Force backgrounds / colors to print (otherwise white-only). */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  /* Hide chrome: sidebar, header bar, toolbars, mode pickers, form controls. */
  .app-sidebar, .app-header, .app-footer,
  .main-sidebar, .main-header, .main-footer,
  .navbar, nav.navbar,
  .breadcrumb,
  form,
  .btn-group,
  .form-check.form-switch,
  .dropdown { display: none !important; }

  /* Re-show the report's own headline area (which contained a form/partial we just nuked
     — keep only what's a true heading, not the toolbar form). */
  h3, .card-header, .card-title { display: block !important; }

  /* Make the layout full-width on paper. */
  .app-main, main, .container, .container-fluid { padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
  .col-md-3, .col-md-4, .col-md-6, .col-md-8, .col-md-9, .col-md-12,
  .col-lg-3, .col-lg-4, .col-lg-6, .col-lg-8, .col-lg-12 { max-width: 100% !important; flex: 0 0 100% !important; }

  /* Cards lose their borders so the page feels printed, not boxed. */
  .card { border: none !important; box-shadow: none !important; }
  .card-body { padding: .25rem !important; }

  /* Compact the tables. */
  .is-table, .bs-table, .cf-table {
    font-size: 10pt;
    width: 100% !important;
  }
  .is-table th, .is-table td,
  .bs-table th, .bs-table td,
  .cf-table th, .cf-table td {
    padding: .15rem .35rem !important;
  }
  .is-table td.amt, .bs-table td.amt, .cf-table td.amt,
  .is-table th.amt, .bs-table th.amt, .cf-table th.amt { min-width: 0 !important; }

  /* Section / total row backgrounds stay (gives the printed report structure).
     Use the admin-configurable table palette so print mirrors what's on screen. */
  .is-table tr.section td,
  .bs-table tr.section-head td,
  .cf-table tr.section td,
  .bva-table tr.section td,
  .ws-table tr.section td,
  .tr-table tr.highlight td {
    background: var(--ah-table-section-bg) !important;
  }
  .is-table tr.bottom-total td,
  .bs-table tr.grand-total td,
  .cf-table tr.total td,
  .bva-table tr.total td,
  .ws-table tr.grand td {
    background: var(--ah-table-total-bg) !important;
    border-color: var(--ah-table-total-border) !important;
  }
  .is-table tr.subtotal td,
  .bs-table tr.section-total td,
  .cf-table tr.subtotal td,
  .bva-table tr.subtotal td,
  .ws-table tr.subtotal td {
    border-color: var(--ah-table-total-border) !important;
  }

  /* Don't break rows across pages where possible. */
  tr, .card { page-break-inside: avoid; }

  /* Hide collapse arrows (no interaction on paper). */
  .is-collapse .arrow, .bs-collapse .arrow, .tree-arrow { display: none !important; }

  /* Tables start collapsed on screen; expand every row when printing so the
     full statement is on paper (overrides the inline display:none). */
  .bs-table tr, .is-table tr, .cf-table tr, .bva-table tr { display: table-row !important; }

  /* Page setup — landscape works better for the wider "Show all" mode. */
  @page { size: auto; margin: 1cm; }
}

/* ---- Month/year picker (Views/Shared/_MonthPicker.cshtml + js/month-picker.js) ---- */
.js-month-picker .mp-menu { min-width: 240px; }
.js-month-picker .mp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; }
.js-month-picker .mp-grid .mp-month {
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  border-radius: .4rem;
  padding: .4rem 0;
  font-size: .85rem;
  cursor: pointer;
}
.js-month-picker .mp-grid .mp-month:hover { border-color: rgba(0, 139, 204, .5); }
.js-month-picker .mp-grid .mp-month.selected {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
  color: #fff;
  font-weight: 600;
}

/* ---- Hierarchical collapse for report tables (js/report-tree.js) ---- */
.report-tree .tree-toggle { cursor: pointer; user-select: none; }
.report-tree .tree-arrow { display: inline-block; width: 1em; margin-right: .15rem; transition: transform .15s; }
.report-tree tr.collapsed .tree-arrow { transform: rotate(-90deg); }
/* Child rows hidden by default (everything starts collapsed); report-tree.js reveals
   them with display:table-row as parents are expanded. */
.report-tree tr[data-parent] { display: none; }
