/*
 * Manager fines and zones: presentation only.
 * Financial formulas, source data and handlers live elsewhere and are protected.
 */

#fines-modal {
  --fines-bg: #0d0e0f;
  --fines-row: #111214;
  --fines-hover: #17181a;
  --fines-line: rgba(255, 255, 255, 0.09);
  --fines-line-strong: rgba(255, 255, 255, 0.16);
  --fines-text: #f5f5f2;
  --fines-muted: #989994;
  --fines-accent: #e8ff38;
  --fines-danger: #ff625d;
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  padding: 0 !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  overflow: hidden !important;
  background: var(--fines-bg) !important;
  color-scheme: dark;
}

#fines-modal .fines-ledger-shell {
  width: 100vw !important;
  max-width: none !important;
  height: 100dvh !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 0 env(safe-area-inset-bottom) !important;
  display: block !important;
  overflow-x: clip !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  background: var(--fines-bg) !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

#fines-modal .fines-ledger-shell::selection,
#fines-modal .fines-ledger-shell *::selection {
  color: #090a0b;
  background: var(--fines-accent);
}

#fines-modal .fines-ledger-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: max(7px, env(safe-area-inset-top)) 18px 7px;
  background: rgba(13, 14, 15, 0.97);
  border-bottom: 1px solid var(--fines-line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

#fines-modal .fines-ledger-header h2 {
  margin: 0;
  color: var(--fines-text);
  font-size: clamp(18px, 2vw, 22px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

#fines-modal .fines-ledger-header p {
  display: none;
}

#fines-modal .fines-icon-button,
#fines-modal .fines-back-button {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 1px solid var(--fines-line-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--fines-text);
  cursor: pointer;
}

#fines-modal .fines-icon-button {
  padding: 0;
  font-size: 25px;
  line-height: 1;
}

#fines-modal .fines-back-button {
  padding: 0 14px;
  font-size: 13px;
  font-weight: 750;
}

#fines-modal .fines-icon-button:hover,
#fines-modal .fines-back-button:hover {
  background: var(--fines-hover);
}

#fines-modal .fines-icon-button:focus-visible,
#fines-modal .fines-back-button:focus-visible,
#fines-modal select:focus-visible,
#fines-modal input:focus-visible,
#fines-modal button:focus-visible {
  outline: 2px solid var(--fines-accent);
  outline-offset: 2px;
}

#fines-modal .fines-period-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(300px, 1fr) minmax(260px, 1.5fr);
  align-items: end;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--fines-line);
}

#fines-modal .fines-field {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--fines-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

#fines-modal .fines-date-range {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#fines-modal .fines-field select,
#fines-modal .fines-field input {
  width: 100% !important;
  min-width: 0 !important;
  height: 40px;
  margin: 0;
  padding: 0 11px;
  border: 1px solid var(--fines-line-strong);
  border-radius: 9px;
  background: var(--fines-row);
  color: var(--fines-text);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  box-shadow: none;
}

#fines-modal .fines-period-note {
  align-self: center;
  margin: 15px 0 0;
  color: var(--fines-muted);
  font-size: 11px;
  line-height: 1.35;
}

#fines-modal .fines-ledger-section,
#fines-modal .fines-manual-section,
#fines-modal .fines-detail-block {
  margin: 0;
  padding: 10px 18px 0;
}

#fines-modal .fines-manual-section {
  padding-top: 8px;
}

#fines-modal .fines-section-heading,
#fines-modal .fines-detail-heading {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 4px;
}

#fines-modal .fines-section-heading h3,
#fines-modal .fines-detail-heading h3 {
  margin: 0;
  color: var(--fines-text);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

#fines-modal .fines-section-heading p {
  margin: 0;
  color: var(--fines-muted);
  font-size: 11px;
  line-height: 1.3;
}

#fines-modal .fines-table-shell,
#fines-modal .fines-manual-table-shell,
#fines-modal .fines-detail-table-shell {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

#fines-modal table {
  width: 100% !important;
  max-width: 100% !important;
  display: table !important;
  overflow: visible !important;
  border-collapse: collapse;
  table-layout: fixed;
  font-variant-numeric: tabular-nums;
}

#fines-modal thead {
  display: table-header-group !important;
}

#fines-modal tbody {
  display: table-row-group !important;
}

#fines-modal tr {
  display: table-row !important;
}

#fines-modal th,
#fines-modal td {
  overflow: hidden;
  border: 0;
  border-bottom: 1px solid var(--fines-line);
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

#fines-modal th {
  height: 26px;
  padding: 3px 10px;
  background: transparent;
  color: var(--fines-muted);
  font-size: 10px;
  font-weight: 750;
  line-height: 1;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

#fines-modal td {
  height: 37px;
  padding: 5px 10px;
  color: var(--fines-text);
  font-size: 13px;
  line-height: 1.2;
}

#fines-modal tbody tr:hover {
  background: var(--fines-hover) !important;
}

#fines-modal #fines-table th:first-child,
#fines-modal #fines-table-body td:first-child {
  display: none;
}

#fines-modal #fines-table th:nth-child(2) { width: 40%; }
#fines-modal #fines-table th:nth-child(3) { width: 27%; }
#fines-modal #fines-table th:nth-child(4) { width: 15%; }
#fines-modal #fines-table th:nth-child(5) { width: 18%; }

#fines-modal #fines-table th:nth-child(5) {
  text-align: right;
}

#fines-modal .fines-sort-button {
  width: 100%;
  min-width: 0;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--fines-muted);
  font: inherit;
  font-weight: inherit;
  line-height: 1.15;
  text-align: center;
  text-transform: inherit;
  cursor: pointer;
}

#fines-modal .fines-sort-button > span:first-child {
  min-width: 0;
  white-space: normal;
}

#fines-modal th:nth-child(5) .fines-sort-button {
  justify-content: flex-end;
}

#fines-modal .fines-sort-button.is-active {
  color: var(--fines-text);
}

#fines-modal .fines-sort-button:focus-visible {
  outline: 2px solid var(--fines-accent);
  outline-offset: 1px;
}

#fines-modal .fines-sort-arrow {
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-1px) rotate(45deg);
}

#fines-modal #fines-table-body tr {
  cursor: pointer;
}

#fines-modal #fines-table-body td:nth-child(2) {
  color: var(--fines-text) !important;
  font-weight: 750 !important;
  text-decoration: none !important;
}

#fines-modal #fines-table-body td:nth-child(3) span {
  max-width: 100%;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  padding: 3px 6px !important;
  border-radius: 6px !important;
  font-size: 9px !important;
  line-height: 1 !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#fines-modal #fines-table-body td:nth-child(4) {
  font-weight: 750;
}

#fines-modal #fines-table-body td:last-child,
#fines-modal #fines-detail-tbody td:last-child,
#fines-modal #manual-fines-table-body td:last-child {
  color: var(--fines-danger) !important;
  font-weight: 800 !important;
  text-align: right;
}

#fines-modal .fines-detail-block {
  padding-top: 12px;
  scroll-margin-top: 72px;
}

#fines-modal .fines-detail-heading {
  min-height: 44px;
}

#fines-modal .fines-detail-heading h3 {
  min-width: 0;
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#fines-modal #fines-detail-tbody .fines-detail-group {
  background: var(--fines-bg) !important;
}

#fines-modal #fines-detail-tbody .fines-detail-group:hover {
  background: var(--fines-bg) !important;
}

#fines-modal #fines-detail-tbody .fines-detail-group td {
  height: 38px;
  padding: 13px 10px 7px !important;
  border-bottom-color: var(--fines-line-strong);
  color: var(--fines-text) !important;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-align: left !important;
  text-transform: none;
}

#fines-modal #fines-detail-tbody .fines-detail-group-lates td,
#fines-modal #fines-detail-tbody .fines-detail-group-nonzone td {
  padding-top: 20px !important;
}

#fines-modal #fines-detail-tbody .fines-detail-group td span {
  color: var(--fines-muted);
  font-weight: 650;
}

#fines-modal .fines-detail-table-shell th:nth-child(1) { width: 18%; }
#fines-modal .fines-detail-table-shell th:nth-child(2) { width: 62%; }
#fines-modal .fines-detail-table-shell th:nth-child(3) { width: 20%; text-align: right; }

#fines-modal .fines-detail-table-shell td:nth-child(2) {
  white-space: normal;
}

#fines-modal #fines-detail-tbody button,
#fines-modal #manual-fines-table-body button {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#fines-modal .fines-manual-table-shell th:nth-child(1) { width: 14%; }
#fines-modal .fines-manual-table-shell th:nth-child(2) { width: 18%; }
#fines-modal .fines-manual-table-shell th:nth-child(3) { width: 22%; }
#fines-modal .fines-manual-table-shell th:nth-child(4) { width: 30%; }
#fines-modal .fines-manual-table-shell th:nth-child(5) { width: 16%; text-align: right; }

#fines-modal #manual-fines-table-body td[colspan],
#fines-modal #fines-detail-tbody td[colspan] {
  height: 34px;
  padding: 5px 10px !important;
  color: var(--fines-muted) !important;
  text-align: center !important;
}

#fines-modal .fines-rules {
  display: flex;
  gap: 18px;
  margin: 10px 18px 18px;
  padding-top: 8px;
  border-top: 1px solid var(--fines-line);
}

#fines-modal .fines-rules p {
  margin: 0;
  color: var(--fines-muted);
  font-size: 10px;
  line-height: 1.35;
}

#fines-modal .fines-rules strong {
  color: var(--fines-text);
}

#fines-modal:has(#fines-detail-block[style*="display: block"]) .fines-period-panel,
#fines-modal:has(#fines-detail-block[style*="display: block"]) .fines-ledger-section,
#fines-modal:has(#fines-detail-block[style*="display: block"]) .fines-manual-section,
#fines-modal:has(#fines-detail-block[style*="display: block"]) .fines-rules {
  display: none;
}

@media (max-width: 760px) {
  #fines-modal .fines-ledger-header {
    min-height: 52px;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding-right: 10px;
    padding-left: 10px;
  }

  #fines-modal .fines-ledger-header h2 {
    font-size: 17px !important;
  }

  #fines-modal .fines-period-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px 8px;
    padding: 7px 10px 8px;
  }

  #fines-modal .fines-field-week {
    grid-column: 1 / -1;
  }

  #fines-modal .fines-date-range {
    grid-column: 1 / -1;
  }

  #fines-modal .fines-field {
    gap: 3px;
    font-size: 10px;
  }

  #fines-modal .fines-field select,
  #fines-modal .fines-field input {
    height: 34px;
    padding: 0 8px;
    border-radius: 7px;
    font-size: 11px;
  }

  #fines-modal .fines-period-note {
    display: none;
  }

  #fines-modal .fines-ledger-section,
  #fines-modal .fines-manual-section,
  #fines-modal .fines-detail-block {
    padding-right: 10px;
    padding-left: 10px;
  }

  #fines-modal .fines-ledger-section {
    padding-top: 5px;
  }

  #fines-modal .fines-manual-section {
    padding-top: 5px;
  }

  #fines-modal .fines-section-heading {
    min-height: 24px;
    margin-bottom: 0;
  }

  #fines-modal .fines-section-heading h3 {
    font-size: 13px;
  }

  #fines-modal .fines-section-heading p,
  #fines-modal .fines-rules {
    display: none;
  }

  #fines-modal th {
    height: 23px;
    padding: 2px 4px;
    font-size: 9px;
  }

  #fines-modal td {
    height: 34px;
    padding: 3px 4px;
    font-size: 11px;
  }

  #fines-modal #fines-table th:nth-child(2) { width: 36%; }
  #fines-modal #fines-table th:nth-child(3) { width: 25%; }
  #fines-modal #fines-table th:nth-child(4) { width: 20%; text-align: center; }
  #fines-modal #fines-table th:nth-child(5) { width: 19%; }

  #fines-modal #fines-table-body td:nth-child(3) span {
    min-height: 20px;
    padding: 2px 4px !important;
    font-size: 8px !important;
  }

  #fines-modal #fines-table th:nth-child(4) .fines-sort-button {
    font-size: 8px;
  }

  #fines-modal #fines-table th:nth-child(5) .fines-sort-button {
    font-size: 9px;
  }

  #fines-modal #fines-table-body td:nth-child(4) {
    text-align: center;
  }

  #fines-modal #fines-table-body td:nth-child(4) strong,
  #fines-modal #fines-table-body td:nth-child(5) {
    font-size: 11px !important;
  }

  #fines-modal .fines-detail-block {
    padding-top: 7px;
    scroll-margin-top: 76px;
  }

  #fines-modal .fines-detail-heading {
    min-height: 44px;
    margin-bottom: 3px;
  }

  #fines-modal .fines-detail-heading h3 {
    font-size: 15px;
  }

  #fines-modal .fines-detail-table-shell thead,
  #fines-modal #manual-fines-table thead {
    display: none !important;
  }

  #fines-modal .fines-detail-table-shell table,
  #fines-modal #fines-detail-tbody,
  #fines-modal #manual-fines-table,
  #fines-modal #manual-fines-table-body {
    display: block !important;
  }

  #fines-modal #fines-detail-tbody tr,
  #fines-modal #manual-fines-table-body tr {
    width: 100%;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--fines-line);
  }

  #fines-modal #fines-detail-tbody td,
  #fines-modal #manual-fines-table-body td {
    width: auto !important;
    min-width: 0;
    height: auto;
    display: block;
    padding: 0 4px !important;
    border: 0;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  #fines-modal #fines-detail-tbody td:nth-child(1),
  #fines-modal #manual-fines-table-body td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    color: var(--fines-muted);
    font-size: 10px;
  }

  #fines-modal #fines-detail-tbody td:nth-child(2),
  #fines-modal #manual-fines-table-body td:nth-child(2) {
    grid-column: 1;
    color: var(--fines-muted);
    font-size: 10px;
  }

  #fines-modal #fines-detail-tbody td:nth-child(3),
  #fines-modal #manual-fines-table-body td:nth-child(3) {
    grid-column: 1;
    font-weight: 700;
  }

  #fines-modal #fines-detail-tbody td:nth-child(4),
  #fines-modal #manual-fines-table-body td:nth-child(4) {
    grid-column: 1;
    font-size: 10px;
  }

  #fines-modal #fines-detail-tbody td:nth-child(5),
  #fines-modal #manual-fines-table-body td:nth-child(5) {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    white-space: nowrap;
  }

  #fines-modal #fines-detail-tbody tr:has(td[colspan]),
  #fines-modal #manual-fines-table-body tr:has(td[colspan]) {
    display: block !important;
    padding: 0;
  }

  #fines-modal #fines-detail-tbody td[colspan],
  #fines-modal #manual-fines-table-body td[colspan] {
    width: 100% !important;
    height: 30px;
    display: block !important;
    padding: 8px 4px !important;
  }

  #fines-modal #fines-detail-tbody .fines-detail-group {
    padding: 0;
    border-bottom: 0;
  }

  #fines-modal #fines-detail-tbody .fines-detail-group td {
    height: auto;
    padding: 13px 4px 7px !important;
    border-bottom: 1px solid var(--fines-line-strong);
    font-size: 12px;
  }

  #fines-modal #fines-detail-tbody .fines-detail-group-lates td,
  #fines-modal #fines-detail-tbody .fines-detail-group-nonzone td {
    padding-top: 21px !important;
  }

  #fines-modal #fines-detail-tbody tr:not(.fines-detail-group):not(:has(td[colspan])) td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    color: var(--fines-muted);
    font-size: 10px;
  }

  #fines-modal #fines-detail-tbody tr:not(.fines-detail-group):not(:has(td[colspan])) td:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
    color: var(--fines-text);
    font-size: 11px;
    font-weight: 700;
  }

  #fines-modal #fines-detail-tbody tr:not(.fines-detail-group):not(:has(td[colspan])) td:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    color: var(--fines-danger) !important;
    text-align: right;
    white-space: nowrap;
  }

  #fines-modal #fines-detail-tbody tr:last-child:not(:has(td[colspan])) {
    grid-template-columns: 1fr auto;
  }

  #fines-modal #fines-detail-tbody tr:last-child:not(:has(td[colspan])) td:first-child {
    grid-column: 1;
    grid-row: 1;
    color: var(--fines-text) !important;
    text-align: left !important;
  }

  #fines-modal #fines-detail-tbody tr:last-child:not(:has(td[colspan])) td:last-child {
    grid-column: 2;
    grid-row: 1;
  }
}

@media (max-width: 340px) {
  #fines-modal .fines-ledger-header h2 {
    font-size: 16px !important;
  }

  #fines-modal td {
    padding-right: 3px;
    padding-left: 3px;
    font-size: 10px;
  }

  #fines-modal #fines-table-body td:nth-child(3) span {
    font-size: 7px !important;
  }

  #fines-modal #fines-table th:nth-child(4) .fines-sort-button,
  #fines-modal #fines-table th:nth-child(5) .fines-sort-button {
    font-size: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #fines-modal *,
  #fines-modal *::before,
  #fines-modal *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
