:root {
  --surface-0: #f7f6f3;
  --surface-1: #ffffff;
  --surface-2: #ffffff;
  --text-primary: #1c1c1a;
  --text-secondary: #6b6a64;
  --text-muted: #9a9992;
  --border: #e3e1da;
  --border-strong: #c7c5bb;
  --bg-accent: #e6f1fb;
  --text-accent: #0c447c;
  --bg-warning: #faeeda;
  --text-warning: #633806;
  /* The app had four copies of this green and no name for it, so the next
     person to need one would have picked a fifth. */
  --text-success: #307750;
  --text-success-strong: #276241;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

/* Full-bleed: spans the whole viewport, independent of .page's width. */
.topbar {
  height: 64px;
  margin: 0;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

/* Aligns the bar's own content back to the same column as .page--wide's
   content below it, so the brand/tabs don't drift to the raw screen edges
   on a wide monitor. */
.topbar__inner {
  max-width: 1280px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  box-sizing: border-box;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
}

.topbar__left {
  display: flex;
  align-items: stretch;
  gap: 32px;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
}

.topbar__brand i {
  color: var(--text-accent);
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-accent);
  color: var(--text-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
}

.logout-link {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
}

.prompt {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0 0 1.25rem;
}

.card__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--bg-accent);
  color: var(--text-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.card__title {
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 4px;
}

.btn {
  border: 1px solid var(--border-strong);
  background: transparent;
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn:hover {
  background: var(--surface-0);
}

/* Small square icon-only button (e.g. removing an attached file row). */
.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface-1);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.auth-page {
  max-width: 360px;
  margin: 4rem auto;
  padding: 0 1.5rem;
}

.auth-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.field input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 10px;
  font-size: 14px;
}

.field input[type="file"]::file-selector-button {
  height: 100%;
  padding: 0 16px;
  margin-right: 10px;
  border: none;
  border-right: 1px solid var(--border);
  background: #f5f5f5;
  cursor: pointer;
}

.errorlist {
  color: #a32d2d;
  font-size: 13px;
  padding-left: 0;
  list-style: none;
  margin: 0 0 1rem;
}

.placeholder {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Workflow pages opt into a wider column via {% block page_class %} -
   .page's own max-width is the only thing that can widen the layout, an
   inner wrapper's max-width can't grow past what its parent already gives
   it. */
.page--wide {
  max-width: 1280px;
}

/* --- Top tab bar (Pay cycle consolidation / File generation) --- */
.tabbar {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.tabbar__tab {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  color: var(--text-secondary);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tabbar__tab:hover {
  color: var(--text-primary);
}

.tabbar__tab--active {
  border-bottom-color: var(--text-accent);
  color: var(--text-primary);
  font-weight: 600;
}

/* --- Sub-tabs within a workflow page (e.g. Summary / Bill lines) --- */
.subtabs {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

.subtabs__tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px 10px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.subtabs__tab .count {
  color: var(--text-muted);
  font-weight: 400;
}

.subtabs__tab--active {
  border-bottom-color: var(--text-accent);
  color: var(--text-primary);
}

/* --- New run / Previous runs two-column layout --- */
.run-grid {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 32px;
  align-items: start;
}

/* --- OpCo form / callout two-column layout --- */
.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(0, 300px);
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .run-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* --- OpCo "Active" toggle: a real <button type=submit>, purely CSS switch --- */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.switch__track {
  width: 32px;
  height: 18px;
  border-radius: 999px;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  background: var(--border-strong);
  transition: background-color 0.15s ease;
  flex: none;
}

.switch--on .switch__track {
  justify-content: flex-end;
  background: var(--text-success);
}

.switch__knob {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  display: block;
}

.switch__label {
  font-weight: 600;
  color: var(--text-muted);
}

.switch--on .switch__label {
  color: var(--text-primary);
}

/* --- Pills: OpCo "In Summary/Trends" toggle + bill-line Status --- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
}

button.pill {
  cursor: pointer;
}

.pill--in {
  border-color: #c8dcf0;
  background: var(--bg-accent);
  color: var(--text-accent);
}

.pill--warning {
  border-color: #f0ddb8;
  background: var(--bg-warning);
  color: var(--text-warning);
}

/* --- OpCo "Summary column order" preview chips --- */
.chip-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.chip-row__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-accent);
  color: var(--text-accent);
  border-radius: 6px;
  padding: 3px 9px;
}

.chip__pos {
  font-size: 11px;
  opacity: 0.7;
}

/* --- Callouts: warning banners and info boxes --- */
.callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 8px;
}

.callout p {
  margin: 0;
}

.callout--warning {
  background: var(--bg-warning);
  color: var(--text-warning);
}

/* Boxed variant: standalone info box (e.g. "one manual step left"), not
   stacked with other callouts, so no bottom margin and a bigger radius. */
.callout--boxed {
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 0;
  flex-direction: column;
}

/* --- Disclosures: callouts the reader can fold away ---
   Native <details>/<summary>, so it works with no JS and is keyboard and
   screen-reader accessible for free. The chevron replaces the browser's
   default marker so it sits on the right and matches across browsers. */
.disclosure {
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 8px;
}

.disclosure > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  padding: 8px 14px;
  font-weight: 600;
}

.disclosure > summary::-webkit-details-marker {
  display: none;
}

.disclosure > summary::after {
  content: "";
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.disclosure[open] > summary::after {
  transform: rotate(-135deg);
}

.disclosure__body {
  padding: 0 14px 10px 36px;
}

.disclosure__body p {
  margin: 0 0 6px;
}

.disclosure__body p:last-child {
  margin-bottom: 0;
}

.disclosure--warning {
  background: var(--bg-warning);
  color: var(--text-warning);
}

/* Quiet variant: a single muted line until opened - reference material
   for first-time users that shouldn't cost everyone else any attention. */
.disclosure--quiet > summary {
  display: inline-flex;
  padding: 4px 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}

.disclosure--quiet > summary::after {
  margin-left: 4px;
}

.disclosure--quiet > summary:hover {
  color: var(--text-secondary);
}

.disclosure--quiet .disclosure__body {
  padding: 4px 0 0 20px;
  color: var(--text-secondary);
  max-width: 72ch;
}

/* --- Tables as cards --- */
.table-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead tr {
  background: var(--surface-0);
  color: var(--text-secondary);
  text-align: left;
}

.data-table th {
  padding: 10px 16px;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.data-table tbody tr {
  border-top: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
}

/* Per-table vertical rhythm - the design uses a slightly different cell
   height for each of these three table types. */
.data-table--summary td {
  padding: 11px 16px;
}

.data-table--lines td {
  padding: 10px 16px;
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table .num--strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.data-table tbody tr.is-clickable {
  cursor: pointer;
}

.data-table tbody tr.is-clickable:hover {
  background: #faf9f7;
}

.data-table th.total {
  background: #f2f0ec;
}

.data-table td.total {
  background: #faf9f7;
  font-weight: 600;
}

.data-table tr.total-row {
  border-top: 1px solid var(--border-strong);
  background: var(--surface-0);
}

.data-table tr.total-row td {
  padding: 13px 16px;
  font-weight: 600;
}

.data-table tr.total-row td.total {
  background: #f2f0ec;
  color: var(--text-accent);
}

/* --- Panels: card shell with a tinted header strip (New run, OpCo details) --- */
.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.panel__head {
  padding: 12px 20px;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.panel__body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel__body .field {
  margin-bottom: 0;
}

.panel__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  background: var(--surface-0);
  border-top: 1px solid var(--border);
}

/* --- Primary / upload buttons --- */
.btn--primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  background: var(--text-accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn--primary:hover {
  background: #08315a;
}

.btn--upload {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 36px;
  background: var(--text-success);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
}

.btn--upload:hover {
  background: var(--text-success-strong);
}

/* --- New run: readiness checklist card --- */
.newrun {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(28, 28, 26, 0.04);
}

.newrun__head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.newrun__head-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.newrun__title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.newrun__count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.newrun__progress {
  margin-top: 10px;
  height: 4px;
  border-radius: 999px;
  background: #eae8e2;
  overflow: hidden;
}

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

.newrun__steps {
  padding: 8px 22px 4px;
}

.newrun__step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.newrun__step:last-child {
  padding-bottom: 18px;
  border-bottom: none;
}

/* Empty dashed ring until the step is satisfied, then a green check. */
.newrun__check {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 999px;
  color: var(--text-success);
  display: flex;
  align-items: center;
  justify-content: center;
}

.newrun__check svg {
  display: none;
  width: 18px;
  height: 18px;
}

.newrun__check.is-done {
  border: none;
  margin-top: 1px;
}

.newrun__check.is-done svg {
  display: block;
}

.newrun__step-main {
  flex: 1;
  min-width: 0;
}

.newrun__step-title {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 600;
}

.newrun__step-hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.newrun__step-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.newrun__filelist {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.newrun__file {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.newrun__file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

.newrun__file-name--picked {
  color: var(--text-primary);
  font-weight: 600;
}

/* Text-button "Choose"/"Replace" wrapping a real file input. */
.newrun__pick {
  position: relative;
  overflow: hidden;
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-accent);
  cursor: pointer;
}

.newrun__pick:hover {
  color: #08315a;
}

.newrun__pick input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.newrun__drop {
  border: 1px dashed var(--border-strong);
  background: var(--surface-0);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

/* Active state while a file is dragged over the dropzone. */
.newrun__drop--active {
  border-color: var(--text-accent);
  background: var(--bg-accent);
}

.newrun__drop .btn--upload {
  width: auto;
  height: 34px;
  padding: 0 14px;
}

.newrun__drop-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.newrun__foot {
  padding: 16px 22px;
  background: var(--surface-0);
  border-top: 1px solid var(--border);
}

.newrun__foot .btn--primary {
  width: 100%;
  height: 40px;
  font-size: 14px;
}

/* --- Screen titles and back links --- */
.backlink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.backlink:hover {
  color: var(--text-primary);
}

.screen-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}

/* --- Misc badges/chips --- */
.badge--neutral {
  background: #eae8e2;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
}

.chip--muted {
  background: var(--surface-0);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 400;
}
