:root {
  --bg: #f4f7fb;
  --card: rgba(255, 255, 255, 0.9);
  --line: #dbe3ee;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #1d4ed8;
  --brand-soft: rgba(37, 99, 235, 0.08);
  --warning: #b45309;
  --warning-soft: #fff7ed;
  --danger: #be123c;
  --success: #15803d;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

[x-cloak] { display: none !important; }

html { scroll-behavior: smooth; }
body {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 30%),
    radial-gradient(circle at 85% 15%, rgba(15, 23, 42, 0.04), transparent 20%),
    var(--bg);
}

.app-bg { min-height: 100vh; }
.app-card {
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.shadow-soft { box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12); }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(255,255,255,.7);
  padding: .4rem .75rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-chip, .btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  border-radius: 999px;
  padding: .88rem 1.1rem;
  font-size: .95rem;
  font-weight: 700;
  transition: transform .18s ease, background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.nav-chip:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.24);
  outline-offset: 2px;
}

.nav-surface {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .6rem;
  width: 100%;
  padding: .7rem;
  border-radius: 1.35rem;
  border: 1px solid rgba(148, 163, 184, .22);
  background: rgba(255,255,255,.62);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02), 0 10px 24px rgba(15, 23, 42, 0.04);
}

.nav-chip {
  border: 1px solid rgba(148, 163, 184, .25);
  background: rgba(255,255,255,.8);
  color: #334155;
  min-height: 2.85rem;
  justify-content: center;
  width: 100%;
  padding-inline: 1rem;
  text-align: center;
  line-height: 1.15;
}

.nav-chip span {
  line-height: 1;
}

.nav-chip i {
  width: 1rem;
  text-align: center;
}
.nav-chip:hover,
.btn-secondary:hover { transform: translateY(-1px); }
.nav-chip-active {
  background: linear-gradient(180deg, #1d4ed8, #1e40af);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 26px rgba(29, 78, 216, 0.22), inset 0 0 0 1px rgba(255,255,255,.14);
}

.nav-chip[aria-current="page"] { position: relative; }

.nav-chip[aria-current="page"]::after {
  content: "";
  position: absolute;
  inset: auto 1rem .28rem 1rem;
  height: 2px;
  border-radius: 999px;
  background: rgba(255,255,255,.9);
}

.btn-primary {
  background: linear-gradient(180deg, #1d4ed8, #1e40af);
  color: white;
  border: 1px solid transparent;
  box-shadow: 0 12px 24px rgba(29, 78, 216, 0.22);
}
.btn-primary:hover { filter: brightness(1.02); }
.btn-primary:disabled {
  opacity: .72;
  cursor: progress;
  transform: none;
}
.btn-secondary {
  background: white;
  color: #334155;
  border: 1px solid rgba(148, 163, 184, .3);
}
.btn-secondary:disabled {
  opacity: .55;
  cursor: not-allowed;
}

@media (min-width: 640px) {
  .nav-surface { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .nav-surface {
    display: flex;
    width: auto;
    justify-content: flex-end;
    flex-wrap: wrap;
    padding: .65rem;
  }

  .nav-chip {
    width: auto;
    white-space: nowrap;
  }
}

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

.table-scroll > table {
  width: 100%;
}

.table-scroll table {
  min-width: 0;
}

.data-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.batch-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.snapshot-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.summary-band-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.data-table thead th,
.data-table tbody td {
  font-size: .93rem;
}

.data-table thead th.col-id,
.data-table tbody td.col-id {
  white-space: nowrap;
}

.data-table thead th.col-name,
.data-table tbody td.col-name,
.data-table thead th.col-div,
.data-table tbody td.col-div {
  min-width: 170px;
}

.batch-table thead th,
.batch-table tbody td,
.snapshot-table thead th,
.snapshot-table tbody td,
.summary-band-table thead th,
.summary-band-table tbody td {
  padding: .8rem .85rem;
  vertical-align: top;
}

.batch-table thead th,
.snapshot-table thead th,
.summary-band-table thead th,
.agency-table thead th {
  font-size: .7rem;
  letter-spacing: .12em;
}

.batch-table tbody tr,
.snapshot-table tbody tr,
.summary-band-table tbody tr,
.agency-table tbody tr {
  transition: background-color .16s ease;
}

.batch-table tbody tr:hover,
.snapshot-table tbody tr:hover,
.summary-band-table tbody tr:hover,
.agency-table tbody tr:hover {
  background: rgba(248,250,252,.85);
}

.batch-table .col-date { width: 160px; }
.batch-table .col-agency { width: 130px; }
.batch-table .col-status { width: 110px; }
.batch-table .col-day { width: 88px; }
.batch-table .col-files { width: 24%; }
.batch-table .col-totals { width: 15%; }
.batch-table .col-notes { width: auto; }
.batch-table .col-action { width: 110px; }

.snapshot-table .col-id { width: 9%; }
.snapshot-table .col-name { width: 14%; }
.snapshot-table .col-div { width: 18%; }
.snapshot-table tbody td.col-name .cell-clip { max-width: 100%; }
.snapshot-table tbody td.col-id,
.snapshot-table tbody td.col-money { white-space: nowrap; }
.snapshot-table tbody td.col-div { min-width: 0; }

.summary-band-table .col-name { width: auto; }
.summary-band-table .col-id { width: 11%; }
.summary-band-table .col-money { width: 18%; }

.agency-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.agency-table .col-code { width: 110px; }
.agency-table .col-name { width: auto; }
.agency-table .col-status { width: 130px; }

.stack-tight {
  display: grid;
  gap: .35rem;
}

.stack-tight p {
  margin: 0;
}

.table-clip {
  display: flex;
  align-items: center;
  gap: .45rem;
  min-width: 0;
}

.table-clip > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-clip > i {
  flex: 0 0 auto;
}

.batch-table .stat-label,
.snapshot-table .stat-label,
.summary-band-table .stat-label {
  font-size: .66rem;
}

.contacts-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.contacts-table thead th,
.contacts-table tbody td {
  font-size: .8rem;
  padding: .55rem .6rem;
}

.contacts-table-compact {
  min-width: 0;
}

.contacts-table-compact thead th,
.contacts-table-compact tbody td {
  padding: .5rem .55rem;
  font-size: .76rem;
}

.contacts-table .col-name {
  min-width: 0;
}

.contacts-table .col-id {
  min-width: 0;
}

.contract-copy {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  max-width: 100%;
  border-radius: 999px;
  padding: .22rem .45rem;
  color: #0f172a;
  font-weight: 800;
  font-size: .82rem;
  white-space: nowrap;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.contract-copy:hover {
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px #bfdbfe;
  transform: translateY(-1px);
}

.contract-copy i {
  color: #64748b;
  font-size: .78rem;
}

.contract-copy small {
  color: #166534;
  font-size: .68rem;
  font-weight: 800;
}

.contacts-table .col-div {
  min-width: 0;
}

.contacts-table .col-id,
.contacts-table .col-money,
.contacts-table .col-div {
  vertical-align: middle;
}

.contacts-table .col-id,
.contacts-table .col-money,
.contacts-table .col-div {
  vertical-align: middle;
}

.data-table tbody td.col-name .cell-clip {
  display: inline-block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
}

.contacts-table tbody td.col-name .cell-clip {
  max-width: 100%;
  display: block;
}

.data-table thead th.col-money,
.data-table tbody td.col-money {
  min-width: 145px;
  background: rgba(248, 250, 252, 0.45);
}

.contacts-table thead th.col-money,
.contacts-table tbody td.col-money {
  min-width: 0;
  width: 102px;
}

.contacts-table thead th.col-id,
.contacts-table tbody td.col-id {
  width: 84px;
}

.contacts-table thead th.col-name,
.contacts-table tbody td.col-name {
  width: 120px;
}

.contacts-table thead th.col-div,
.contacts-table tbody td.col-div {
  width: 132px;
}

.contacts-table .pill {
  padding: .18rem .45rem;
  font-size: .66rem;
}

.contacts-table thead th {
  font-size: .64rem;
}

.contacts-table tbody td {
  line-height: 1.2;
}

.contacts-table tbody td.col-name .cell-clip,
.contacts-table tbody td.col-name .cell-clip,
.contacts-table tbody td.col-id,
.contacts-table tbody td.col-money,
.contacts-table tbody td.col-div {
  overflow: hidden;
  text-overflow: ellipsis;
}

.contacts-table .contract-copy {
  max-width: 100%;
}

.contacts-table .contract-copy span {
  max-width: 76px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contacts-table .col-name .cell-clip {
  max-width: 100%;
  display: block;
}

.contacts-table .col-name {
  width: 120px;
}

.contacts-table .col-id {
  width: 84px;
}

.contacts-table .col-money {
  width: 102px;
}

.contacts-table .col-div {
  width: 132px;
}

.contacts-table tbody tr td:first-child {
  position: relative;
}

.contacts-table tbody td,
.agency-table tbody td,
.batch-table tbody td,
.snapshot-table tbody td,
.summary-band-table tbody td {
  border-bottom-color: rgba(226,232,240,.75);
}

.data-table thead th.col-money {
  background: rgba(241, 245, 249, 0.96);
}

.data-table tbody tr:nth-child(even) {
  background: rgba(248,250,252,.55);
}

.row-alt { background: rgba(248,250,252,.48); }

.data-table tbody tr:hover .col-money {
  background: rgba(239, 246, 255, .7);
}

.arrears-table tfoot th,
.arrears-table tfoot td {
  padding: 1rem 1.15rem;
  border-top: 1px solid rgba(226,232,240,.9);
  font-size: .95rem;
}

.arrears-table tfoot th {
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .72rem;
  color: #475569;
}

.app-table tfoot th,
.app-table tfoot td {
  padding: 1rem 1.15rem;
  border-top: 1px solid rgba(226,232,240,.9);
  vertical-align: top;
}

.app-table tfoot th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: #475569;
}

.summary-link {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: #1d4ed8;
  font-weight: 700;
  text-decoration: none;
}

.summary-link:hover { text-decoration: underline; }

.flash {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .9rem 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(148,163,184,.25);
  background: rgba(255,255,255,.88);
  box-shadow: 0 10px 24px rgba(15,23,42,.06);
}
.flash-success { border-color: rgba(34,197,94,.25); color: #166534; }
.flash-error { border-color: rgba(244,63,94,.25); color: #9f1239; }
.flash-warning { border-color: rgba(245,158,11,.25); color: #92400e; }

.status-tile, .metric-card, .note-box {
  border: 1px solid rgba(148,163,184,.18);
  background: rgba(255,255,255,.8);
  border-radius: 1.25rem;
}
.status-tile {
  min-width: 10rem;
  padding: 1rem 1.1rem;
  display: grid;
  gap: .2rem;
  justify-items: start;
}
.status-label, .stat-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--muted);
}
.status-tile strong { font-size: 2rem; line-height: 1; }

.metric-card {
  padding: .9rem 1rem;
  display: grid;
  gap: .2rem;
}
.metric-card span { font-size: .72rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 700; }
.metric-card strong { font-size: 1.35rem; line-height: 1.1; color: var(--text); }

.upload-field { display: grid; gap: .5rem; }
.field-label { font-weight: 700; color: #0f172a; display: inline-flex; align-items: center; gap: .5rem; }
.field-meta { font-size: .78rem; color: var(--muted); }
.field-help, .field-error { font-size: .85rem; line-height: 1.5; }
.field-help { color: var(--muted); }
.field-error { color: var(--danger); }

.file-dropzone {
  display: grid;
  gap: .9rem;
  padding: 1rem;
  border-radius: 1.25rem;
  border: 1px dashed rgba(100,116,139,.35);
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,250,252,.94));
  cursor: pointer;
}
.file-dropzone:hover { border-color: rgba(37,99,235,.45); background: linear-gradient(180deg, rgba(239,246,255,.94), rgba(255,255,255,.98)); }
.dropzone-copy { display: flex; gap: .9rem; align-items: flex-start; }
.dropzone-copy > i { font-size: 1.15rem; color: var(--brand); margin-top: .15rem; }
.dropzone-title { font-weight: 700; color: #0f172a; }
.dropzone-help { margin-top: .15rem; font-size: .88rem; color: var(--muted); }
.dropzone-file { font-size: .85rem; font-weight: 600; color: #334155; padding-top: .2rem; border-top: 1px solid rgba(148,163,184,.15); }

.check-item { display: flex; gap: .6rem; align-items: flex-start; }
.check-item i { color: var(--success); margin-top: .22rem; }
.note-box {
  padding: 1rem;
  display: grid;
  gap: .25rem;
  color: #334155;
}
.note-box strong { color: #0f172a; }

.empty-state {
  display: grid;
  place-items: center;
  gap: .9rem;
  text-align: center;
}

.empty-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--brand);
}

.agency-table thead th,
.agency-table tbody td {
  padding: .95rem 1.1rem;
}

.agency-table tbody tr:hover {
  background: rgba(248,250,252,.85);
}

.agency-table .pill {
  padding-inline: .55rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .65rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.pill-success { background: #ecfdf5; color: #166534; }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-danger { background: #fff1f2; color: var(--danger); }
.pill-neutral { background: #f1f5f9; color: #334155; }

.app-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.app-table thead th {
  position: sticky; top: 0;
  z-index: 1;
  background: rgba(248, 250, 252, .96);
  border-bottom: 1px solid var(--line);
  color: #475569;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  text-align: left;
  padding: 1rem 1.15rem;
  white-space: nowrap;
}
.app-table tbody td {
  border-bottom: 1px solid rgba(226,232,240,.8);
  padding: 1rem 1.15rem;
  vertical-align: top;
}
.app-table tbody tr:hover { background: rgba(248,250,252,.8); }
.app-table-tight tbody td { padding-top: .9rem; padding-bottom: .9rem; }
.row-warning { background: linear-gradient(90deg, rgba(255,247,237,.7), rgba(255,255,255,0)); }

.tabular-nums { font-variant-numeric: tabular-nums; }

[x-cloak] { display: none !important; }

@media (max-width: 1024px) {
  .app-table thead th { top: 74px; }
}
