/* OSP Reports -- Accounting View.
   Dense, spreadsheet-oriented workspace -- deliberately NOT a Kanban-style
   layout. Reuses manage.css's shared tokens (--surface/--border/--text/
   --accent/--text-muted/etc.), same convention as management_osp_reports.css.
   Tabulator's own visual language is overridden minimally below so the grid
   reads as part of this portal, not a bolted-on third-party widget. */

.oa-root {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.oa-tabs {
  display: inline-flex;
  gap: 6px;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 5px;
  width: fit-content;
}

.oa-tab {
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.oa-tab.is-active {
  background: var(--accent);
  color: #fff;
}

.oa-state {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---- summary cards ------------------------------------------------------ */

.oa-summary[hidden],
.oa-toolbar[hidden] {
  display: none;
}

.oa-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.oa-summary-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface, #fff);
  padding: 10px 12px;
  position: relative;
}

.oa-summary-card__label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  font-weight: 700;
}

.oa-summary-card__value {
  font-size: 18px;
  font-weight: 800;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.oa-period-nav {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

/* ---- toolbar -------------------------------------------------------------- */

.oa-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface, #fff);
}

.oa-search-wrap {
  flex: 1 1 220px;
  min-width: 180px;
}

.oa-search,
.oa-select {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2, #f2f2f2);
  font-size: 12.5px;
  color: var(--text-primary, var(--text));
  width: 100%;
}

.oa-select {
  width: auto;
  min-width: 130px;
  cursor: pointer;
}

.oa-mini-btn {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface, #fff);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary, var(--text));
  cursor: pointer;
  white-space: nowrap;
}

.oa-mini-btn:hover {
  border-color: var(--border-hover);
}

.oa-clear-filters {
  margin-left: auto;
}

.oa-date-filter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.oa-date-filter input {
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2, #f2f2f2);
  font-size: 12px;
  padding: 0 6px;
}

.oa-multiselect {
  position: relative;
}

.oa-multiselect-btn {
  text-align: left;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.oa-multiselect-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 200px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-modal, 0 12px 32px rgba(0, 0, 0, 0.15));
  padding: 6px;
}

.oa-multiselect-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
  border-radius: 6px;
  cursor: pointer;
}

.oa-multiselect-item:hover {
  background: var(--surface2, #f2f2f2);
}

/* ---- grid ------------------------------------------------------------- */

.oa-grid-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface, #fff);
}

.tabulator {
  font-size: 12.5px;
  font-family: inherit;
  border: none;
}

.tabulator .tabulator-header {
  background: var(--surface2, #f2f2f2);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.tabulator-row {
  border-bottom: 1px solid var(--border);
}

.tabulator-row.tabulator-row-even {
  background: var(--surface, #fff);
}

.tabulator-row:hover {
  background: var(--surface2, #f2f2f2) !important;
}

.tabulator-row.tabulator-selected {
  background: var(--accent-soft, rgba(255, 130, 0, 0.08)) !important;
}

.tabulator .tabulator-cell.tabulator-frozen {
  background: inherit;
}

.oa-status-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface2, #eee);
  color: var(--text-muted);
}

.oa-status-pill.oa-status-paid {
  background: rgba(48, 209, 88, 0.12);
  color: #1a7d34;
}

.oa-status-pill.oa-status-ready {
  background: rgba(255, 214, 10, 0.18);
  color: #8a6100;
}

.oa-status-pill.oa-status-rejected {
  background: rgba(255, 59, 48, 0.1);
  color: #b42318;
}

/* ---- fixed calc bar + sticky bulk bar ----------------------------------- */

.oa-calc-bar {
  position: sticky;
  bottom: 0;
  align-self: flex-end;
  background: var(--text, #111);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow-card, 0 2px 8px rgba(0, 0, 0, 0.15));
  z-index: 15;
}

.oa-bulk-bar {
  position: sticky;
  bottom: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow-modal, 0 12px 32px rgba(0, 0, 0, 0.2));
  z-index: 16;
}

/* An author `display` rule on the same element beats the browser's own
   `[hidden] { display: none }` UA rule (author styles win the cascade
   regardless of selector specificity ties) -- without this, setting
   `el.hidden = true` in JS would stop having any visual effect at all.
   Same reasoning applies wherever else a class sets `display` directly. */
.oa-bulk-bar[hidden] {
  display: none;
}

.oa-bulk-bar .oa-mini-btn {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

/* ---- select all filtered ------------------------------------------------- */

.oa-select-all-filtered {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface2, #f2f2f2);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.oa-select-all-filtered[hidden] {
  display: none;
}

.oa-select-all-filtered:hover {
  text-decoration: underline;
}

/* ---- modals (Change Status / Payment Date, bulk progress, select-all confirm) */

.oa-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.oa-modal-overlay[hidden] {
  display: none;
}

.oa-modal {
  background: var(--surface, #fff);
  border-radius: 16px;
  padding: 22px 24px;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  box-shadow: var(--shadow-modal, 0 24px 60px rgba(0, 0, 0, 0.22));
}

.oa-modal--wide {
  width: min(560px, calc(100vw - 32px));
}

.oa-statement-review-groups,
.oa-statement-result-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
}

.oa-statement-group-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2, #f7f7f7);
}

.oa-statement-group-row__label {
  font-weight: 800;
  font-size: 13px;
}

.oa-statement-group-row__meta {
  font-size: 11.5px;
  color: var(--text-muted);
}

.oa-statement-group-row__total {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.oa-statement-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.oa-statement-result-row__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.oa-statement-result-row__title {
  font-weight: 800;
  font-size: 13px;
}

.oa-statement-result-row__meta {
  font-size: 11px;
  color: var(--text-muted);
}

.oa-statement-result-row a.oa-mini-btn {
  text-decoration: none;
}

.oa-modal-title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 800;
}

.oa-modal-subtotal {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
}

.oa-modal-field {
  margin-bottom: 12px;
}

.oa-modal-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.oa-modal-field select,
.oa-modal-field input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2, #f2f2f2);
  font-size: 13px;
  box-sizing: border-box;
}

.oa-modal-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-primary, var(--text));
  margin-bottom: 14px;
}

.oa-modal-error {
  background: rgba(255, 59, 48, 0.1);
  color: #b42318;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  margin-bottom: 12px;
}

.oa-modal-success {
  background: rgba(52, 199, 89, 0.12);
  color: #1a7431;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  margin-bottom: 12px;
}

.oa-send-email-recipients {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.oa-send-email-recipient {
  margin-bottom: 0;
}

.oa-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.oa-mini-btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.oa-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface2, #eee);
  overflow: hidden;
  margin: 10px 0;
}

.oa-progress-bar__fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.2s ease;
}

.oa-progress-result {
  font-size: 13px;
  margin-top: 8px;
  white-space: pre-line;
}

/* ---- responsive: grid scrolls horizontally, filters wrap ---------------- */

@media (max-width: 900px) {
  .oa-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .oa-select,
  .oa-multiselect {
    width: 100%;
  }

  .oa-clear-filters {
    margin-left: 0;
  }
}
