/* Shared financial-table design system for Reimbursement / Deductions
   Accounting management pages -- reuses manage.css's .mp-panel/.mp-btn
   color tokens, no new color system. */

.acct-root {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.acct-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.acct-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  margin-right: 8px;
}

.acct-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 420px;
}

.acct-search-wrap .acct-search {
  flex: 1 1 auto;
}

.acct-search-wrap .acct-mini-btn {
  flex: 0 0 auto;
}

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

.acct-quick-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.acct-chip {
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2, #f2f2f2);
  font-size: 12.5px;
  cursor: pointer;
}

.acct-chip.is-active {
  background: var(--accent, #ff5a00);
  color: #fff;
  border-color: transparent;
}

.acct-chip--clear {
  opacity: 0.7;
}

.acct-filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.acct-date-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.acct-date-filter input {
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 6px;
  background: var(--surface2, #f2f2f2);
}

.acct-multiselect {
  position: relative;
}

.acct-multiselect-btn {
  min-width: 140px;
  text-align: left;
  cursor: pointer;
}

.acct-multiselect-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 220px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 6px;
}

.acct-multiselect-menu[hidden] {
  display: none;
}

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

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

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

.acct-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 70vh;
}

.acct-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.acct-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface2, #f2f2f2);
  text-align: left;
  padding: 8px 10px;
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  cursor: default;
  z-index: 5;
}

.acct-table thead th[data-sort] {
  cursor: pointer;
}

.acct-table thead th[data-sort]:hover {
  background: var(--surface3, #e8e8e8);
}

.acct-table thead th.is-sorted::after {
  content: " \25BC";
  font-size: 9px;
}

.acct-table thead th.is-sorted.is-asc::after {
  content: " \25B2";
}

.acct-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-soft, #eee);
  white-space: nowrap;
}

.acct-table tbody tr {
  cursor: pointer;
}

.acct-table tbody tr:hover {
  background: var(--surface2, #f8f8f8);
}

.acct-num {
  text-align: right;
}

.acct-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.acct-pill--green { background: rgba(52, 199, 89, 0.15); color: #1a7431; }
.acct-pill--red { background: rgba(255, 59, 48, 0.12); color: #b42318; }
.acct-pill--amber { background: rgba(255, 159, 10, 0.15); color: #92400e; }
.acct-pill--gray { background: rgba(120, 120, 128, 0.15); color: #555; }
.acct-pill--blue { background: rgba(0, 122, 255, 0.12); color: #1d4ed8; }

.acct-file-link {
  font-size: 12px;
  margin-right: 6px;
}

.acct-pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 8px;
  font-size: 12.5px;
}

.acct-mini-btn {
  height: 28px;
  padding: 0 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface2, #f2f2f2);
  font-size: 12px;
  cursor: pointer;
}

.acct-mini-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Detail drawer */
.acct-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  justify-content: flex-end;
  z-index: 100;
}

.acct-drawer-overlay[hidden] {
  display: none;
}

.acct-drawer {
  width: min(480px, 100vw);
  height: 100vh;
  background: var(--surface, #fff);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.acct-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface, #fff);
}

.acct-drawer-header h2 {
  margin: 0;
  font-size: 16px;
}

.acct-drawer-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.acct-drawer-field {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft, #eee);
}

.acct-drawer-field__label {
  color: var(--text-muted);
  flex-shrink: 0;
}

.acct-drawer-field__value {
  text-align: right;
  word-break: break-word;
}

.acct-drawer-section-title {
  font-size: 13px;
  font-weight: 700;
  margin-top: 12px;
}

.acct-subitem-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  margin-bottom: 6px;
}

/* ---- Deductions details modal (centered, styled consistently with the
   OSP Reporting report-details modal -- backdrop dim/blur, flex-centered
   dialog card, rounded corners, sticky header, internally-scrolling body,
   near-full-viewport on short/mobile screens). Reimbursement's side
   drawer (.acct-drawer*) is untouched -- this is a separate set of
   classes used only by the Deductions page. */

.acct-details-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 20, 40, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.acct-details-overlay[hidden] {
  display: none;
}

.acct-details-modal {
  background: var(--surface, #fff);
  border-radius: 20px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.28), 0 4px 20px rgba(0, 0, 0, 0.12);
  width: 100%;
  max-width: 700px;
  height: min(90vh, calc(100vh - 40px));
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.acct-details-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface, #fff);
  border-radius: 20px 20px 0 0;
}

.acct-details-header-text h2 {
  margin: 0;
  font-size: 18px;
}

.acct-details-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.acct-details-close {
  flex-shrink: 0;
  font-size: 20px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.acct-details-body {
  overflow-y: auto;
  padding: 18px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1 1 auto;
  min-height: 0;
}

.acct-details-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.acct-details-section__title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft, #eee);
  margin-bottom: 6px;
}

.acct-details-amount {
  font-size: 22px;
  font-weight: 700;
}

.acct-details-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}

.acct-details-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 2px 0 6px;
  font-style: italic;
}

.acct-date-flag {
  color: #9a5b00;
  cursor: help;
  border-bottom: 1px dotted #9a5b00;
}

@media (max-height: 760px), (max-width: 640px) {
  .acct-details-overlay {
    align-items: flex-start;
    padding: 10px;
  }
  .acct-details-modal {
    height: calc(100dvh - 20px);
    max-height: calc(100dvh - 20px);
    border-radius: 14px;
  }
  .acct-details-header {
    border-radius: 14px 14px 0 0;
    padding: 14px 16px;
  }
  .acct-details-body {
    padding: 14px 16px 18px;
  }
}

.acct-editable {
  border-bottom: 1px dashed var(--accent, #ff5a00);
  cursor: pointer;
}

.acct-drawer-field__value-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  max-width: 62%;
}

.acct-editable-display {
  cursor: pointer;
  border-bottom: 1px dashed var(--accent, #ff5a00);
}

.acct-editable-display:hover {
  opacity: 0.8;
}

.acct-edit-icon {
  font-size: 10px;
  opacity: 0.6;
  margin-left: 3px;
}

.acct-editable-input,
.acct-editable-select {
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--accent, #ff5a00);
  border-radius: 6px;
  font-size: 12.5px;
  min-width: 140px;
}

.acct-save-status {
  font-size: 10.5px;
  color: var(--text-muted);
}

.acct-save-status.is-error {
  color: #b42318;
  font-weight: 600;
}

.acct-save-status.is-saved {
  color: #1a7431;
}

/* Mobile: cards instead of a squeezed table */
.acct-card-wrap {
  display: none;
  flex-direction: column;
  gap: 8px;
}

.acct-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.acct-card-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  padding: 3px 0;
}

.acct-card-row__label {
  color: var(--text-muted);
}

@media (max-width: 760px) {
  /* Reimbursement has no manual view toggle -- keep its original
     CSS-driven "cards on mobile" fallback exactly as before, scoped so it
     never fights Deductions' explicit, user-controlled view toggle (see
     .acct-view-switch / AcctTable.wireViewToggle below), which must be able
     to show Table view on any screen width when the user picks it. */
  [data-module="reimbursement"] .acct-table-wrap { display: none; }
  [data-module="reimbursement"] .acct-card-wrap[data-has-items] { display: flex; }
  .acct-filter-row { flex-direction: column; align-items: stretch; }
  .acct-multiselect-btn { width: 100%; }
}

/* ---- View switch (table/cards toggle, JSA-style) ---------------------- */

.acct-results-head {
  display: flex;
  justify-content: flex-end;
}

.acct-view-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.acct-view-switch__button {
  height: 32px;
  padding: 0 14px;
  border: none;
  background: var(--surface2, #f2f2f2);
  font-size: 12.5px;
  cursor: pointer;
  border-right: 1px solid var(--border);
}

.acct-view-switch__button:last-child {
  border-right: none;
}

.acct-view-switch__button.is-active {
  background: var(--accent, #ff5a00);
  color: #fff;
  font-weight: 600;
}

/* ---- New Deduction button + modal --------------------------------------- */

.acct-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2, #f2f2f2);
  font-size: 13px;
  cursor: pointer;
}

.acct-btn--primary {
  background: var(--accent, #ff5a00);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}

.acct-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.acct-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

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

.acct-modal {
  background: var(--surface, #fff);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.acct-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface, #fff);
  z-index: 1;
}

.acct-modal-header h2 {
  margin: 0;
  font-size: 17px;
}

.acct-modal-body {
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.acct-form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.acct-form-field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.acct-required {
  color: #b42318;
}

.acct-form-field input[type="text"],
.acct-form-field input[type="number"],
.acct-form-field input[type="file"],
.acct-form-field select,
.acct-form-field textarea {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2, #f2f2f2);
  font-size: 13.5px;
  box-sizing: border-box;
  width: 100%;
}

.acct-form-field textarea {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
  white-space: pre-wrap;
}

.acct-field-error {
  color: #b42318;
  font-size: 12px;
}

.acct-file-selected {
  font-size: 12px;
  color: var(--text-muted);
}

.acct-form-message {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
}

.acct-form-message.is-success {
  background: #e3f5e9;
  color: #176b35;
}

.acct-form-message.is-error {
  background: #ffe3e5;
  color: #a3212d;
}

.acct-form-message.is-warning {
  background: #fff4e0;
  color: #9a5b00;
}

.acct-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.acct-single-select .acct-multiselect-btn {
  width: 100%;
}

.acct-multiselect-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 6px 8px 2px;
}

.acct-multiselect-empty {
  padding: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.acct-multiselect-clear {
  width: 100%;
  margin-top: 6px;
  height: 28px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}

.acct-file-retry {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- Deductions card layout (JSA-style card, deduction-specific fields) */

.acct-card-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 12px;
  align-content: start;
}

/* The `display: grid` above has the same specificity as the browser's own
   `[hidden] { display: none }` UA rule, and an author rule wins any tie --
   without this, setting the `hidden` attribute would stop actually hiding
   the element. */
.acct-card-wrap[hidden] {
  display: none;
}

[data-module="reimbursement"] .acct-card-wrap {
  display: none;
  grid-template-columns: none;
}

@media (max-width: 760px) {
  [data-module="reimbursement"] .acct-card-wrap[data-has-items] { display: flex; }
}

.acct-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.acct-card-title {
  font-size: 14px;
}

.acct-card-amount {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.acct-card-desc {
  font-size: 12.5px;
  color: var(--text);
  padding: 4px 0;
}

.acct-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}

.acct-card-footer {
  padding-top: 6px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}

.acct-card-footer .acct-mini-btn {
  width: 100%;
  text-align: center;
}

@media (max-width: 480px) {
  .acct-modal { max-width: 100%; border-radius: 0; max-height: 100vh; height: 100%; }
}
