/* New Jersey CART After Action Reporting Portal — OPS CONNECT */

:root {
  --nj-blue: #0a3161;
  --nj-gold: #c5a000;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1a1d23;
  --muted: #5c6370;
  --border: #d8dee8;
  --accent: #1e5a8a;
  --success: #1b7f4a;
  --danger: #b42318;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(10, 49, 97, 0.08);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--nj-blue);
  color: #fff;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.site-header {
  background: linear-gradient(135deg, var(--nj-blue) 0%, #0d4a7a 100%);
  color: #fff;
  padding: 0.75rem 1rem;
  padding-top: max(0.75rem, env(safe-area-inset-top));
  box-shadow: 0 2px 12px rgba(10, 49, 97, 0.25);
}

@media (min-width: 768px) {
  .site-header {
    padding: 1rem 1.5rem;
  }
}

.site-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.site-header__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
}

.site-header__tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Keep bell + menu on-screen: brand must shrink; long title otherwise pushes tools past the viewport */
@media (max-width: 767px) {
  .site-header__row {
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
  }

  .brand {
    flex: 1 1 0;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .site-header__tools {
    flex-shrink: 0;
    margin-left: auto;
  }

  .pending-header-btn {
    padding: 0.4rem 0.5rem;
    gap: 0.25rem;
  }

  .nav-toggle__text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .nav-toggle {
    position: relative;
    gap: 0;
    padding: 0.55rem 0.65rem;
  }
}

.pending-header-btn:not([hidden]) {
  display: inline-flex;
}

.pending-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.65rem;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(180, 35, 24, 0.35);
  color: #fff;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
}

.pending-header-btn:hover,
.pending-header-btn:focus-visible {
  background: rgba(180, 35, 24, 0.55);
  outline: none;
}

.pending-header-btn__bell {
  display: flex;
  line-height: 0;
}

.pending-header-btn__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.4rem;
  font-size: 0.75rem;
  font-weight: 800;
  background: #fff;
  color: var(--danger);
  border-radius: 999px;
}

.pending-banner {
  background: #fde8e6;
  border-bottom: 2px solid var(--danger);
  color: var(--text);
}

.pending-banner.hidden {
  display: none !important;
}

.pending-banner__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.pending-banner__text {
  margin: 0;
  flex: 1 1 220px;
  font-size: 0.95rem;
  font-weight: 500;
}

.pending-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.main-nav__btn--pending {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.nav-pending-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  font-size: 0.7rem;
  font-weight: 800;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  line-height: 1;
}

.nav-pending-badge[hidden] {
  display: none !important;
}

.stat-card--alert .stat-card__value--alert {
  color: var(--danger);
}

.btn--compact {
  min-height: 38px;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

.draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  max-width: 22rem;
}

.draft-actions .btn {
  min-height: 36px;
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
}

@media (min-width: 768px) {
  .site-header__inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem 1rem;
  }

  .site-header__row {
    grid-column: 1;
  }

  .main-nav {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    width: auto;
    max-width: min(560px, 48vw);
    display: flex !important;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    border-top: none;
    padding-top: 0;
  }
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.brand__title {
  font-size: clamp(1.05rem, 4vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
  line-height: 1.25;
  max-width: 100%;
}

.brand__subtitle {
  font-size: 0.8rem;
  opacity: 0.9;
  font-weight: 400;
  margin: 0;
}

.brand__badge {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--nj-gold);
  font-weight: 600;
}

.nav-toggle {
  display: none;
  align-items: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 0.9rem;
  min-height: 44px;
  min-width: 44px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: var(--radius);
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
}

.nav-toggle__icon {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 -6px 0 #fff, 0 6px 0 #fff;
}

.nav-toggle.is-active .nav-toggle__icon {
  box-shadow: none;
  background: #fff;
  transform: rotate(45deg);
}

.nav-toggle.is-active .nav-toggle__icon::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 2px;
  background: #fff;
  transform: rotate(-90deg);
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
}

.main-nav button {
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.85rem;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  touch-action: manipulation;
}

@media (max-width: 767px) {
  .nav-toggle {
    display: inline-flex;
  }

  .main-nav {
    display: none;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.5rem;
    padding-top: 0.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
  }

  .main-nav.is-open {
    display: flex;
  }

  .main-nav button {
    width: 100%;
    text-align: left;
    justify-content: flex-start;
  }
}

.main-nav button:hover,
.main-nav button:focus-visible {
  background: rgba(255, 255, 255, 0.22);
  outline: none;
}

.main-nav button.is-active {
  background: #fff;
  color: var(--nj-blue);
  border-color: #fff;
  font-weight: 600;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
  .layout {
    padding: 1.5rem;
  }
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 768px) {
  .panel {
    padding: 1.5rem;
  }
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  color: var(--nj-blue);
  border-bottom: 2px solid var(--nj-gold);
  padding-bottom: 0.5rem;
}

.panel h3 {
  margin: 1.25rem 0 0.75rem;
  font-size: 1rem;
  color: var(--text);
}

.panel p.lead {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.hidden {
  display: none !important;
}

.grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .grid--2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid--3 {
    grid-template-columns: repeat(3, 1fr);
  }
  .grid--4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="time"],
.field input[type="tel"],
.field select,
.field textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.field textarea {
  min-height: 100px;
  resize: vertical;
}

.field small {
  font-size: 0.75rem;
  color: var(--muted);
}

.inline-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.inline-group label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
  cursor: pointer;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 639px) {
  .form-actions .btn {
    flex: 1 1 auto;
    min-width: min(100%, 200px);
    justify-content: center;
  }
}

.btn {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  min-height: 44px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
  touch-action: manipulation;
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--nj-blue);
  color: #fff;
}

.btn--primary:hover {
  filter: brightness(1.08);
}

.btn--secondary {
  background: #e8eef4;
  color: var(--nj-blue);
  border: 1px solid var(--border);
}

.btn--ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}

.stat-card__value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--nj-blue);
}

.stat-card__label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.25rem;
  padding: 0 0.25rem;
}

.table-wrap--report {
  margin-top: 1rem;
}

.table-wrap--report .data-table {
  min-width: 720px;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: #e8eef4;
  color: var(--nj-blue);
  font-weight: 600;
}

.data-table tr:hover td {
  background: #fafbfc;
}

.data-table button.linkish {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  font: inherit;
  padding: 0;
}

.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: flex-end;
}

.search-bar .field {
  flex: 1;
  min-width: 180px;
}

.footer-note {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 49, 97, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: min(640px, 100%);
  width: 100%;
  max-height: min(90vh, 100dvh);
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  padding: 1rem 1.25rem;
  -webkit-overflow-scrolling: touch;
}

.modal--report {
  max-width: min(860px, 100%);
}

@media (min-width: 768px) {
  .modal {
    padding: 1.5rem;
  }
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal__header--report {
  flex-wrap: wrap;
  align-items: center;
}

.modal__header--report h2 {
  flex: 1 1 auto;
  min-width: 10rem;
  margin: 0;
  font-size: 1.15rem;
  color: var(--nj-blue);
}

.modal__header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.modal__close {
  font-size: 1.5rem;
  line-height: 1;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0 0.35rem;
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
}

.modal-body--report {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

/* Structured After Action report (modal + PDF) */
.report-document {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.45;
}

.report-document__masthead {
  text-align: center;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--nj-blue);
}

.report-document__program {
  margin: 0 0 0.25rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.report-document__title {
  margin: 0;
  font-size: 1.2rem;
  color: var(--nj-blue);
  font-weight: 700;
}

.report-document__subtitle {
  margin: 0.35rem 0 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.report-document__refs {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.report-document__meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
  text-align: left;
  padding: 0.85rem;
  background: #f0f4f8;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.report-document__meta-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.report-document__meta-value {
  font-weight: 600;
  color: var(--nj-blue);
  font-size: 0.88rem;
}

.report-document__section {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.report-document__section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.report-document__section-title {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--nj-blue);
  border-left: 3px solid var(--nj-gold);
  padding-left: 0.5rem;
}

.report-document__fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem 1.25rem;
}

@media (max-width: 540px) {
  .report-document__fields {
    grid-template-columns: 1fr;
  }
}

.report-document__field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.report-document__field--full {
  grid-column: 1 / -1;
}

.report-document__label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.report-document__value {
  font-size: 0.9rem;
  color: var(--text);
  word-break: break-word;
}

.report-document__value--multiline {
  white-space: pre-wrap;
}

/* PDF capture: avoid CSS variables where html2canvas fails to resolve them */
.report-pdf-root {
  width: 100%;
  background: #ffffff;
  color: #1a1d23;
  padding: 12px 16px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  box-sizing: border-box;
}

.report-pdf-root .report-document {
  color: #1a1d23;
}

.report-pdf-root .report-document__program,
.report-pdf-root .report-document__label,
.report-pdf-root .report-document__refs,
.report-pdf-root .report-document__meta-label {
  color: #5c6370;
}

.report-pdf-root .report-document__title,
.report-pdf-root .report-document__section-title,
.report-pdf-root .report-document__meta-value {
  color: #0a3161;
}

.report-pdf-root .report-document__subtitle {
  color: #1a1d23;
}

.report-pdf-root .report-document__value {
  color: #1a1d23;
}

.report-pdf-root .report-document__masthead {
  border-bottom-color: #0a3161;
}

.report-pdf-root .report-document__section-title {
  border-left-color: #c5a000;
}

.report-pdf-root .report-document__meta-grid {
  background: #f0f4f8;
  border-color: #d8dee8;
}

.report-pdf-root .report-document__section {
  border-bottom-color: #d8dee8;
}

.toast {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: max(1rem, env(safe-area-inset-bottom));
  margin: 0 auto;
  max-width: 420px;
  background: var(--nj-blue);
  color: #fff;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 60;
  transform: translateY(120%);
  transition: transform 0.3s ease;
  text-align: center;
}

@media (min-width: 480px) {
  .toast {
    left: auto;
    right: 1.5rem;
    bottom: 1.5rem;
    text-align: left;
  }
}

.toast.is-visible {
  transform: translateY(0);
}

.more-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.more-links li {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.more-links li:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.form-ref {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.report-filters {
  margin-top: 0.5rem;
}

.report-filters__grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .report-filters__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.report-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  background: #e8eef4;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.report-summary strong {
  color: var(--nj-blue);
}

.data-table--report td {
  white-space: nowrap;
}

.data-table--report td:nth-child(4) {
  white-space: normal;
  min-width: 8rem;
}
