/*
 * Comp Recon UI layer (2026-09): responsive shell + filter bar v2.
 * Loaded after app.css. app.css is untouched; this file only adds and overrides.
 *
 * Breakpoints: <980px the sidebar becomes a drawer behind a menu button;
 * <760px cards, filters and toolbars stack for a phone.
 */

/* ------------------------------------------------------------- shell --- */

.topbar {
  display: none;
}

.nav-overlay {
  background: rgba(16, 36, 61, 0.42);
  inset: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transition: opacity 0.18s ease;
  z-index: 40;
}

body.nav-open .nav-overlay {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 979px) {
  .app-shell {
    display: block;
  }

  .topbar {
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 10px;
    min-height: 54px;
    padding: 8px 12px;
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .topbar .brand-block {
    background: transparent;
    border: 0;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    padding: 0;
  }

  .topbar .brand {
    font-size: 15px;
  }

  .topbar .brand-subtitle {
    display: none;
  }

  .topbar .brand-mark,
  .topbar .brand-logo {
    height: 32px;
    width: 32px;
  }

  .nav-toggle {
    align-items: center;
    background: var(--panel);
    border: 1px solid #ccd8e5;
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 650;
    gap: 8px;
    min-height: 38px;
    padding: 6px 12px;
  }

  .nav-toggle-bars {
    display: inline-block;
    height: 2px;
    position: relative;
    width: 18px;
    background: currentColor;
    border-radius: 2px;
  }

  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    background: currentColor;
    border-radius: 2px;
    content: "";
    height: 2px;
    left: 0;
    position: absolute;
    width: 18px;
  }

  .nav-toggle-bars::before { top: -6px; }
  .nav-toggle-bars::after { top: 6px; }

  .sidebar {
    border-bottom: 0;
    border-right: 1px solid #cfdbe8;
    bottom: 0;
    box-shadow: 0 12px 40px rgba(16, 36, 61, 0.22);
    display: flex;
    left: 0;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 14px 24px;
    position: fixed;
    top: 0;
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    width: min(320px, 86vw);
    z-index: 50;
  }

  body.nav-open .sidebar {
    transform: none;
  }

  .sidebar .side-nav {
    display: block;
  }

  .sidebar .account-panel {
    margin-top: auto;
  }

  .content-shell {
    padding: 14px 14px 28px;
  }
}

@media (max-width: 979px) and (prefers-reduced-motion: reduce) {
  .sidebar,
  .nav-overlay {
    transition: none;
  }
}

/* ------------------------------------------------- page-level layout --- */

.table-scroll,
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.table-scroll > table {
  margin-top: 0;
  min-width: 100%;
}

.table-scroll-auto {
  margin-top: 10px;
}

@media (max-width: 759px) {
  h1 {
    font-size: 21px;
  }

  .grid,
  .metrics,
  .grid.metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Pages that set a two-pane grid inline (Builder) stack on a phone. */
  .content-shell > .grid[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  .metric-value {
    font-size: 17px;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
  }

  .metrics .card,
  .metrics .metric-link {
    min-height: 0;
    padding: 12px;
  }

  .dashboard-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .dashboard-coverage-pill {
    max-width: 100%;
    width: 100%;
  }

  .dashboard-mom-grid {
    grid-template-columns: 1fr;
  }

  .page-heading,
  .section-head,
  .section-heading,
  .page-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .tabs {
    flex-wrap: nowrap;
    margin-left: -14px;
    margin-right: -14px;
    overflow-x: auto;
    padding: 2px 14px 6px;
    scrollbar-width: thin;
  }

  .tabs a {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .toolbar,
  .toolbar form {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .toolbar form select {
    flex: 1 1 200px;
  }

  .report-export-jobs-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .report-export-actions {
    flex-wrap: wrap;
  }

  .metric-review-alert {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .mom-control-grid,
  .pnl-filters,
  .activation-filter-grid,
  .lookup-form {
    grid-template-columns: 1fr;
  }

  .table-scroll th:first-child,
  .table-scroll td:first-child {
    background: inherit;
    box-shadow: 1px 0 0 #e6edf4;
    left: 0;
    max-width: 46vw;
    min-width: 132px;
    position: sticky;
    white-space: normal;
    z-index: 1;
  }

  .table-scroll thead th:first-child {
    background: #f7fafc;
  }

  .table-scroll tbody td:first-child {
    background: var(--panel);
  }

  .table-scroll tbody tr:hover td:first-child {
    background: #f8fbfd;
  }
}

@media (min-width: 760px) and (max-width: 979px) {
  .grid.metrics,
  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-mom-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mom-control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* -------------------------------------------------------- filter bar --- */

.fbar {
  display: block;
  margin-bottom: 12px;
  padding: 0;
  position: relative;
}

.fbar [hidden] {
  display: none !important;
}

.fbar-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 12px;
}

.fbar-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  color: #10243d;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  gap: 8px;
  padding: 4px 0;
}

.fbar-toggle-icon {
  border: solid #4c6e92;
  border-width: 0 2px 2px 0;
  display: inline-block;
  height: 7px;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  width: 7px;
  margin-top: -3px;
}

.fbar.is-collapsed .fbar-toggle-icon {
  transform: rotate(-45deg);
  margin-top: 2px;
}

.fbar-badge {
  background: var(--blue);
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  min-width: 20px;
  padding: 4px 6px;
  text-align: center;
}

.fbar-active {
  display: flex;
  flex: 1 1 200px;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.fbar-active:empty::before {
  color: var(--muted);
  content: "No filters applied";
  font-size: 12px;
}

.fbar-head-actions {
  display: none;
}

.fbar-chip {
  align-items: center;
  background: var(--blue-soft);
  border: 1px solid #c9d9e8;
  border-radius: 999px;
  color: #22364f;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 12px;
  gap: 5px;
  line-height: 1.2;
  max-width: 100%;
  padding: 4px 8px 4px 9px;
}

.fbar-chip:hover {
  background: #e2ecf5;
  border-color: #b3c8dc;
}

.fbar-chip-field {
  color: #56708b;
  font-weight: 650;
}

.fbar-chip-field::after {
  content: ":";
}

.fbar-chip-value {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fbar-chip-x {
  color: #56708b;
  font-size: 15px;
  line-height: 1;
}

.fbar-body {
  border-top: 1px solid #e6edf4;
  padding: 12px;
}

.fbar.is-collapsed .fbar-body {
  display: none;
}

.fbar-lead {
  margin-bottom: 10px;
}

.fbar-lead .mom-control-grid {
  margin: 0;
}

.fbar-dates {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-bottom: 10px;
}

.fbar-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.fbar-control-label {
  color: #66778b;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.fbar-control select,
.fbar-control input {
  min-height: 36px;
  width: 100%;
}

.fbar-dates .fbar-control {
  flex: 0 1 190px;
}

.fbar-date-note {
  color: var(--muted);
  font-size: 12px;
  padding-bottom: 9px;
}

.fbar-fields {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

.fbar-field {
  position: relative;
}

.fbar-trigger {
  align-items: center;
  background: var(--panel);
  border: 1px solid #d1dbe7;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: 6px;
  min-height: 38px;
  padding: 5px 10px;
  text-align: left;
  width: 100%;
}

.fbar-trigger:hover {
  border-color: #aebfd2;
}

.fbar-trigger:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(72, 106, 143, 0.18);
  outline: 0;
}

.fbar-field.is-active .fbar-trigger {
  background: var(--blue-soft);
  border-color: #9fb8d1;
}

.fbar-field.is-open .fbar-trigger {
  border-color: var(--blue);
}

.fbar-trigger-label {
  color: #56708b;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 650;
}

.fbar-trigger-label::after {
  content: ":";
}

.fbar-trigger-value {
  flex: 1 1 auto;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fbar-trigger-caret {
  border: solid #4c6e92;
  border-width: 0 2px 2px 0;
  flex: 0 0 auto;
  height: 6px;
  margin: -3px 2px 0 0;
  transform: rotate(45deg);
  width: 6px;
}

.fbar-field.is-open .fbar-trigger-caret {
  margin-top: 3px;
  transform: rotate(-135deg);
}

.fbar-panel {
  background: var(--panel);
  border: 1px solid #c9d6e4;
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(16, 36, 61, 0.16);
  left: 0;
  margin-top: 4px;
  min-width: 260px;
  position: absolute;
  top: 100%;
  width: max(100%, 300px);
  z-index: 20;
}

.fbar-panel.is-right {
  left: auto;
  right: 0;
}

.fbar-panel.is-up {
  bottom: 100%;
  margin-bottom: 4px;
  margin-top: 0;
  top: auto;
}

.fbar-panel-search {
  border-bottom: 1px solid #e6edf4;
  padding: 8px;
}

.fbar-panel-search input {
  min-height: 34px;
  width: 100%;
}

.fbar-panel-list {
  max-height: 260px;
  overflow-y: auto;
  padding: 4px 0;
}

.fbar-panel-list:empty::before {
  color: var(--muted);
  content: "Open to load values.";
  display: block;
  font-size: 12px;
  padding: 8px 12px;
}

.fbar-option {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 8px;
  padding: 6px 12px;
}

.fbar-option:hover {
  background: #f3f7fb;
}

.fbar-option input {
  flex: 0 0 auto;
  height: 15px;
  margin: 0;
  min-height: 0;
  padding: 0;
  width: 15px;
}

.fbar-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.fbar-panel-status {
  border-top: 1px solid #e6edf4;
  color: var(--muted);
  font-size: 12px;
  padding: 7px 12px;
}

.fbar-panel-status[data-state="error"] {
  color: #8f3f46;
}

.fbar-panel-status[data-state="loading"] {
  color: #4c6e92;
}

.fbar-panel-foot {
  align-items: center;
  border-top: 1px solid #e6edf4;
  display: flex;
  gap: 10px;
  padding: 8px 10px;
}

.fbar-panel-foot .button {
  margin-left: auto;
}

.fbar-link {
  background: transparent;
  border: 0;
  color: var(--blue);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  padding: 4px 2px;
  text-decoration: underline;
}

.fbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.fbar.is-dirty .fbar-actions .button.primary,
.fbar.is-dirty .fbar-apply {
  box-shadow: 0 0 0 3px rgba(66, 98, 130, 0.22);
}

.fbar-export {
  margin-left: auto;
}

.button.button-small {
  font-size: 12px;
  min-height: 30px;
  padding: 4px 10px;
}

@media (max-width: 759px) {
  .fbar-head {
    padding: 8px 10px;
  }

  .fbar-head-actions {
    display: block;
    margin-left: auto;
  }

  .fbar-apply {
    min-height: 34px;
    padding: 5px 12px;
  }

  .fbar-active {
    flex-basis: 100%;
    order: 3;
  }

  .fbar-body {
    padding: 10px;
  }

  .fbar-dates .fbar-control {
    flex: 1 1 calc(50% - 5px);
  }

  .fbar-dates .fbar-control:first-child {
    flex-basis: 100%;
  }

  .fbar-date-note {
    flex-basis: 100%;
    padding-bottom: 0;
  }

  .fbar-fields {
    grid-template-columns: 1fr;
  }

  .fbar-panel {
    left: 0;
    min-width: 0;
    right: 0;
    width: auto;
  }

  .fbar-panel-list {
    max-height: 40vh;
  }

  .fbar-actions .button,
  .fbar-actions .fbar-export {
    flex: 1 1 auto;
    margin-left: 0;
    text-align: center;
  }

  .fbar-export > summary {
    justify-content: center;
    width: 100%;
  }
}

/* Install Y: Activation Recon and Backpaid page head.
   Action buttons sit in one row beside the title, the total cards fill the
   row evenly (no orphan card), and there is space before the Filters card. */
.activation-title-row { flex-wrap: nowrap; align-items: flex-start; }
.activation-title-row > div:first-child { flex: 1 1 auto; min-width: 0; }
.activation-title-row .page-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.activation-title-row .page-actions form { margin: 0; }
.activation-kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 14px; }
@media (max-width: 900px) {
  .activation-title-row { flex-wrap: wrap; }
  .activation-title-row .page-actions { justify-content: flex-start; }
  .activation-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .activation-kpis { grid-template-columns: 1fr; }
}

/* Install AJ: dashboard statements. Three columns (Revenue, Expense, Net), each a
   list of lines; they stack on a narrow screen. An administrator can rearrange them. */
.dash-statements { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; align-items: stretch; margin-bottom: 14px; }
.dash-statement { display: flex; flex-direction: column; padding: 0; overflow: hidden; border-top: 3px solid #9eb6cd; }
.dash-statement-revenue { border-top-color: #1f9d6b; }
.dash-statement-expense { border-top-color: #c62f45; }
.dash-statement-net { border-top-color: #33557a; }
.dash-statement.is-empty { display: none; }
.dash-statement-head { padding: 12px 16px 10px; border-bottom: 1px solid var(--line, #dbe3ee); }
.dash-statement-head h2 { margin: 0; font-size: 15px; letter-spacing: 0.02em; }
.dash-statement-head p { margin: 2px 0 0; font-size: 12px; }
.dash-lines { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 44px; }
.dash-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 16px; color: inherit; text-decoration: none; border-bottom: 1px solid #eef2f7; }
a.dash-line:hover { background: #f5f8fb; }
.dash-line-label { min-width: 0; font-size: 13px; color: var(--text, #172033); }
.dash-line-label small { display: block; font-size: 11px; color: var(--muted, #617085); }
.dash-line-value { flex: 0 0 auto; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text, #172033); }
.dash-line-value.is-plus { color: var(--green, #12805c); }
.dash-line-value.is-minus { color: var(--red, #c62f45); }
.dash-total { background: #f5f8fb; border-top: 2px solid var(--line-strong, #aebfd2); padding-top: 12px; padding-bottom: 12px; }
.dash-total:last-child { margin-top: auto; border-bottom: 0; }
.dash-total .dash-line-label { font-weight: 700; font-size: 14px; }
.dash-total .dash-line-value { font-size: 20px; font-weight: 700; }
.dash-grand .dash-line-value { font-size: 26px; }
.dash-aside .dash-line-label, .dash-aside .dash-line-value { color: var(--muted, #617085); font-weight: 500; }
.dash-arrange { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-bottom: 8px; }
.dash-arrange form { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin: 0; }
.dash-arrange form[hidden], .dash-arrange button[hidden] { display: none; }
.dash-statements.is-arranging .dash-statement { outline: 2px dashed var(--line-strong, #aebfd2); outline-offset: 2px; cursor: grab; }
.dash-statements.is-arranging .dash-statement.is-empty { display: flex; }
.dash-statements.is-arranging .dash-line { cursor: grab; }
.dash-statements.is-arranging .dash-line::before { content: "\2630"; flex: 0 0 auto; align-self: center; margin-right: -4px; font-size: 12px; color: var(--muted, #617085); }
.dash-statements.is-arranging .dash-line-label { flex: 1 1 auto; }
.dash-statements.is-arranging .dash-total:last-child { margin-top: 0; }
.dash-statements .is-dragging { opacity: 0.45; }
@media (max-width: 1100px) {
  .dash-statements { grid-template-columns: 1fr; }
  .dash-total:last-child { margin-top: 0; }
}

/* Install AK: PNL lines on the dashboard statements, and the setting for administrators. */
.dash-tag { display: inline-block; margin-right: 4px; padding: 1px 6px; border-radius: 999px; background: #e8eef6; color: #33557a; font-size: 10px; font-weight: 700; letter-spacing: 0.05em; vertical-align: 1px; }
.dash-line:not(.dash-pnl):not(.dash-ghost) + .dash-pnl { border-top: 2px dashed var(--line-strong, #aebfd2); }
.dash-pnl { background: #fbfcfe; }
.dash-pnl-total .dash-line-label { font-weight: 700; }
.dash-pnl-total .dash-line-value { font-size: 17px; font-weight: 700; }
.dash-ghost { display: none; }
.dash-statements.is-arranging .dash-ghost { display: flex; opacity: 0.55; }
.dash-pnl-config { position: relative; }
.dash-pnl-config > summary { list-style: none; cursor: pointer; }
.dash-pnl-config > summary::-webkit-details-marker { display: none; }
.dash-pnl-form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: min(440px, 92vw); display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 14px; box-shadow: 0 10px 28px rgba(23, 32, 51, 0.14); }
.dash-arrange .dash-pnl-form { flex-direction: column; flex-wrap: nowrap; align-items: stretch; justify-content: flex-start; }
.dash-pnl .dash-line-label small { font-weight: 400; }
.dash-pnl-form p { margin: 0; font-size: 12px; }
.dash-pnl-switch { display: flex; align-items: center; gap: 8px; }
.dash-pnl-switch input, .dash-pnl-group input { width: auto; height: auto; margin: 0 4px 0 0; }
.dash-pnl-group { display: flex; align-items: center; gap: 12px; padding: 6px 0; border-top: 1px solid #eef2f7; font-size: 13px; }
.dash-pnl-group-name { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.dash-pnl-group label { display: inline-flex; align-items: center; white-space: nowrap; }
.dash-pnl-form .button { align-self: flex-end; }
.dash-pnl-config[open] > summary { border-color: var(--line-strong, #aebfd2); }
