:root {
  --ink: #17212f;
  --muted: #65758b;
  --subtle: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef4f8;
  --line: #d9e1ea;
  --line-strong: #c7d2df;
  --blue: #2457d6;
  --blue-soft: #e8eefc;
  --teal: #0f766e;
  --teal-soft: #e4f5f1;
  --green: #227a48;
  --green-soft: #e8f5ed;
  --amber: #9a650f;
  --amber-soft: #fff4d8;
  --red: #b23b3b;
  --red-soft: #fdeaea;
  --shadow: 0 12px 34px rgba(22, 35, 56, 0.08);
  --focus: rgba(36, 87, 214, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: #eef2f7;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.shell {
  min-height: 100vh;
}

.bootstrap-layout,
.signin-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.10), rgba(36, 87, 214, 0.08)),
    #f5f7fb;
}

.bootstrap-panel,
.signin-panel {
  width: min(100%, 460px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(28px, 5vw, 44px);
}

.brand-mark {
  display: block;
  width: 96px;
  height: auto;
  margin: 0 auto 20px;
}

.bootstrap-panel .eyebrow,
.signin-panel .eyebrow {
  text-align: center;
}

.bootstrap-panel h1,
.signin-panel h1,
.topbar h1,
.screen-header h2,
.panel-heading h3,
.detail-panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.signin-panel h1 {
  text-align: center;
  font-size: 32px;
  line-height: 1.08;
}

.bootstrap-panel h1 {
  text-align: center;
  font-size: 24px;
  line-height: 1.15;
}

.signin-copy {
  color: var(--muted);
  line-height: 1.55;
  text-align: center;
  margin: 14px 0 28px;
}

.signin-form,
.upload-form {
  display: grid;
  gap: 16px;
}

label span,
.month-picker span,
.field span {
  display: block;
  color: #334255;
  font-weight: 700;
  margin-bottom: 8px;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--focus);
}

.primary-action,
.secondary-action,
.app-nav-button,
.table-link,
.text-button {
  border: 0;
  cursor: pointer;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
  padding: 0 18px;
  text-align: center;
}

.primary-action:hover {
  background: #243349;
}

.primary-action:disabled {
  cursor: not-allowed;
  background: #d9e1ea;
  color: #6f7f92;
  opacity: 1;
}

.primary-action:disabled:hover {
  background: #d9e1ea;
}

.compact-action {
  width: auto;
  min-width: 140px;
  white-space: nowrap;
}

.secondary-action,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.secondary-link {
  line-height: 1.15;
}

.secondary-action:hover,
.secondary-link:hover {
  border-color: var(--line-strong);
  background: #f8fafc;
}

.secondary-action:disabled {
  cursor: not-allowed;
  background: #f2f5f8;
  color: #6f7f92;
  opacity: 1;
}

.secondary-action:disabled:hover {
  border-color: var(--line);
  background: #f2f5f8;
}

.compact-secondary {
  min-width: 140px;
  white-space: nowrap;
}

.text-button,
.table-link {
  background: transparent;
  color: var(--blue);
  font-weight: 800;
  padding: 0;
}

.text-link {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.form-error,
.status-line {
  min-height: 22px;
  color: var(--red);
  margin: 0;
}

.form-error[data-tone="success"] {
  color: var(--green);
}

.auth-link {
  justify-self: center;
  min-height: 34px;
  font-size: 15px;
}

.status-line {
  color: var(--teal);
}

.status-line[data-tone="error"] {
  color: var(--red);
}

.status-line[data-tone="success"] {
  color: var(--green);
}

.refresh-status {
  margin: -10px 0 14px;
}

.portal-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #111827;
  color: #e8edf5;
  padding: 18px 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px 8px 20px;
}

.sidebar-mark {
  width: 42px;
  height: auto;
}

.sidebar-brand p {
  margin: 0;
  color: #9fb0c6;
  font-size: 12px;
  font-weight: 800;
}

.sidebar-brand strong {
  display: block;
  overflow: hidden;
  color: white;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav {
  display: grid;
  gap: 4px;
}

.app-nav-button {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  background: transparent;
  color: #b7c3d4;
  font-weight: 800;
  text-align: left;
}

.app-nav-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.app-nav-button.active {
  background: white;
  color: var(--ink);
}

.app-main {
  min-width: 0;
  background: #eef2f7;
}

.topbar {
  position: sticky;
  z-index: 4;
  top: 0;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar-title {
  min-width: 0;
}

.topbar h1 {
  max-width: min(70vw, 760px);
  overflow: hidden;
  font-size: 22px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions,
.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.reports-header .header-actions {
  align-items: flex-end;
}

.billing-account-field {
  min-width: min(280px, 100%);
}

.billing-account-field span {
  margin-bottom: 4px;
  font-size: 11px;
}

.billing-account-field select {
  min-height: 40px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tab-panel {
  container-type: inline-size;
  padding: 24px 28px 36px;
}

.screen-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.screen-header h2 {
  font-size: 26px;
  line-height: 1.15;
}

.screen-copy,
.panel-copy {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.55;
  margin: 8px 0 0;
}

.dashboard-cards,
.metrics-grid,
.billing-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.billing-workspace-panel {
  margin-bottom: 20px;
}

.estimate-notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid #d3a72c;
  border-radius: 10px;
  background: #fff8df;
  color: #5d4707;
}

.billing-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin: 20px 0;
}

.billing-filters,
.pagination-row,
.billing-inline-form {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
}

.billing-filters label,
.billing-inline-form label {
  display: grid;
  gap: 6px;
}

.billing-inline-form .grow {
  flex: 1 1 360px;
}

.billing-inline-form textarea {
  width: 100%;
}

.pagination-row {
  justify-content: flex-end;
  align-items: center;
  padding-top: 14px;
}

.billing-list-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line, #dfe4eb);
}

.billing-list-item:last-child {
  border-bottom: 0;
}

.notification-row {
  display: block;
  margin: 8px 0;
}

.stale-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff0cc;
  color: #6e4b00;
  font-size: 12px;
  font-weight: 700;
}

.error-text {
  display: block;
  color: #a4262c;
  font-size: 12px;
}

.billing-warning-list p {
  margin: 8px 0;
  color: #705510;
}

@media (max-width: 780px) {
  .billing-detail-grid {
    grid-template-columns: 1fr;
  }

  .billing-filters {
    width: 100%;
  }
}

.metrics-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  margin-bottom: 20px;
}

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

#usersMetrics .metric-panel {
  display: grid;
  align-content: center;
  min-height: 96px;
  padding: 18px 20px;
  overflow: hidden;
}

#usersMetrics .metric-panel h3 {
  line-height: 1.2;
  margin-bottom: 10px;
}

#usersMetrics .billing-value {
  line-height: 1.05;
}

#usersMetrics .metric-detail {
  margin-top: 10px;
}

.billing-summary {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.summary-card,
.metric-panel,
.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(22, 35, 56, 0.04);
}

.summary-card {
  padding: 18px;
}

.summary-card span,
.metric-panel h3 {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin: 0 0 8px;
}

.summary-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.15;
}

.summary-card p {
  color: var(--muted);
  line-height: 1.35;
  margin: 8px 0 0;
}

.billing-summary .metric-panel {
  display: grid;
  align-content: center;
  min-height: 108px;
  padding: 16px 18px;
  overflow: hidden;
}

.billing-summary .metric-panel h3 {
  color: #60708a;
  font-size: 13px;
  line-height: 1.2;
  margin-bottom: 8px;
}

.billing-summary .metric-detail {
  margin-top: 8px;
}

.billing-summary .billing-value {
  font-size: 21px;
  line-height: 1.12;
}

.dashboard-grid,
.upload-grid,
.history-layout,
.users-layout,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.dashboard-grid > *,
.upload-grid > *,
.history-layout > *,
.users-layout > *,
.settings-grid > *,
.panel,
.table-wrap,
.metric-panel,
.summary-card {
  min-width: 0;
}

.history-layout {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
}

.users-layout {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  align-items: stretch;
}

.users-table-panel,
.side-panel {
  display: flex;
  flex-direction: column;
  height: min(760px, calc(100vh - 235px));
  min-height: 560px;
}

.users-table-panel {
  min-height: 0;
}

.side-panel {
  overflow: auto;
}

.users-table-panel .panel-heading {
  flex: 0 0 auto;
}

.users-search-label {
  flex: 0 0 auto;
  margin-bottom: 14px;
}

.users-search-label input {
  min-height: 42px;
}

.users-table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.upload-grid {
  align-items: stretch;
}

.panel {
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-heading h3,
.detail-panel h3 {
  font-size: 19px;
  line-height: 1.2;
}

.action-panel p,
.transfer-info p {
  color: var(--muted);
  line-height: 1.58;
  margin: 0 0 18px;
}

.stacked-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.stacked-actions .primary-action,
.stacked-actions .secondary-link {
  flex: 0 0 176px;
  min-width: 176px;
  font-size: 15px;
  line-height: 1.15;
}

.activity-list {
  display: grid;
  gap: 10px;
}

.activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.activity-item strong,
.activity-item span {
  display: block;
}

.activity-item .status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.activity-item div span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.activity-actions {
  display: grid;
  grid-template-columns: minmax(126px, max-content) 104px 118px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.activity-actions.has-review-action {
  grid-template-columns: minmax(126px, max-content) minmax(150px, max-content) 104px 118px;
}

.activity-detail-action,
.activity-issue-action {
  display: flex;
  justify-content: flex-start;
}

.activity-detail-action {
  min-width: 104px;
}

.activity-issue-action {
  min-width: 118px;
}

.activity-detail-action .text-button,
.activity-issue-action .text-button,
.activity-issue-action .issue-ok {
  text-align: left;
  white-space: nowrap;
}

.upload-workbench {
  display: flex;
  flex-direction: column;
  padding: 22px;
}

.transfer-info {
  display: flex;
  flex-direction: column;
}

.transfer-info .secondary-link {
  align-self: flex-start;
  margin-top: auto;
}

.field {
  display: block;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 28px;
  border: 1px dashed #aebbd0;
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfdff, #f4f7fb);
  text-align: center;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.has-file,
.drop-zone.dragging {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.drop-zone-title {
  display: block;
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
  margin: 0;
}

.drop-zone-subtitle {
  display: block;
  color: var(--muted);
  margin: 8px 0 16px;
  overflow-wrap: anywhere;
}

.drop-zone-button {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-weight: 800;
}

.upload-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, max-content);
  align-items: center;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.upload-note {
  max-width: 680px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
}

.upload-footer .primary-action {
  justify-self: end;
  min-width: 190px;
  padding: 0 20px;
}

.upload-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.upload-step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
}

.upload-step-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #b8c4d3;
}

.upload-step.done {
  border-color: #c9e7d6;
  background: var(--green-soft);
  color: var(--green);
}

.upload-step.done .upload-step-dot,
.upload-step.active .upload-step-dot {
  background: currentColor;
}

.upload-step.active {
  border-color: #b9d0f8;
  background: var(--blue-soft);
  color: var(--blue);
}

.upload-preview {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.preview-heading,
.preview-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.preview-heading h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.preview-summary {
  color: var(--muted);
  line-height: 1.5;
  margin: 12px 0 14px;
}

.preview-action-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.preview-action-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.preview-action-item span {
  color: #334255;
  font-weight: 800;
  line-height: 1.25;
}

.preview-action-item strong {
  font-size: 18px;
  line-height: 1;
}

.preview-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.preview-metric {
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.preview-metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin: 0 0 6px;
}

.preview-metric strong {
  display: block;
  font-size: 22px;
  line-height: 1.15;
}

.preview-warnings {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #efd7a1;
  border-radius: 8px;
  background: var(--amber-soft);
  color: var(--amber);
}

.preview-warnings p {
  margin: 0;
  line-height: 1.4;
}

.preview-actions {
  justify-content: flex-start;
  margin-top: 16px;
  flex-wrap: wrap;
}

.trust-list {
  display: grid;
  gap: 12px;
  margin: 0 0 18px;
}

.trust-list div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.trust-list dt {
  font-weight: 900;
}

.trust-list dd {
  color: var(--muted);
  margin: 3px 0 0;
}

.requirements-panel {
  margin-top: 18px;
}

.requirements-list {
  color: var(--muted);
  line-height: 1.7;
  margin: 0;
  padding-left: 18px;
}

.comparison-card {
  padding: 18px;
}

.metric-list {
  display: grid;
  gap: 8px;
}

.metric-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  color: var(--muted);
  line-height: 1.28;
}

.metric-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.metric-row strong {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 17px;
  text-align: right;
}

.billing-value {
  display: block;
  color: var(--ink);
  font-size: 22px;
  overflow-wrap: anywhere;
}

.metric-detail {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.embedded-table {
  border-radius: 8px;
  box-shadow: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.history-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 940px;
  table-layout: fixed;
}

.monthly-reports-table {
  border-collapse: separate;
  border-spacing: 0;
}

.statement-history-table {
  table-layout: fixed;
  min-width: 980px;
}

.users-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 0;
  table-layout: fixed;
}

.users-table th,
.users-table td {
  vertical-align: middle;
}

.users-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.sort-header-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

.sort-header-button:hover,
.sort-header-button:focus-visible {
  color: var(--blue);
}

.sort-header-button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
  border-radius: 6px;
}

.sort-indicator {
  position: relative;
  flex: 0 0 10px;
  width: 10px;
  height: 14px;
}

.sort-indicator::before,
.sort-indicator::after {
  content: "";
  position: absolute;
  left: 1px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: 0.35;
}

.sort-indicator::before {
  top: 1px;
  border-bottom: 5px solid var(--muted);
}

.sort-indicator::after {
  bottom: 1px;
  border-top: 5px solid var(--muted);
}

.users-table th[data-sort-direction="asc"] .sort-indicator::before {
  opacity: 1;
  border-bottom-color: var(--teal);
}

.users-table th[data-sort-direction="desc"] .sort-indicator::after {
  opacity: 1;
  border-top-color: var(--teal);
}

.users-table th:nth-child(1),
.users-table td:nth-child(1) {
  width: 30%;
}

.users-table th:nth-child(2),
.users-table td:nth-child(2) {
  width: 38%;
}

.users-table th:nth-child(3),
.users-table td:nth-child(3),
.users-table th:nth-child(4),
.users-table td:nth-child(4) {
  width: 16%;
}

.statement-history-table th,
.statement-history-table td {
  vertical-align: middle;
}

.statement-history-table th:nth-child(1),
.statement-history-table td:nth-child(1) {
  width: 28%;
}

.statement-history-table th:nth-child(2),
.statement-history-table td:nth-child(2) {
  width: 13%;
}

.statement-history-table th:nth-child(3),
.statement-history-table td:nth-child(3) {
  width: 15%;
}

.statement-history-table th:nth-child(4),
.statement-history-table td:nth-child(4),
.statement-history-table th:nth-child(5),
.statement-history-table td:nth-child(5) {
  width: 14%;
}

.statement-history-table th:nth-child(6),
.statement-history-table td:nth-child(6) {
  width: 16%;
}

.monthly-reports-table tbody tr,
.history-table tbody tr,
.users-table tbody tr {
  cursor: pointer;
}

.monthly-reports-table tbody tr:hover td,
.history-table tbody tr:hover td,
.users-table tbody tr:hover td {
  background: #f8fafc;
}

.monthly-reports-table .action-cell {
  display: table-cell;
}

.statement-history-table .action-cell {
  display: table-cell;
  vertical-align: middle;
}

.statement-action-stack {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.statement-history-table td:nth-child(4),
.statement-history-table td:nth-child(5) {
  font-variant-numeric: tabular-nums;
}

.billing-type-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  min-width: 104px;
  padding: 0 12px;
  border-radius: 999px;
  color: #334155;
  background: #eef2f7;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.billing-type-pill.postpaid {
  color: #1d4ed8;
  background: #e7efff;
}

.billing-type-pill.prepaid {
  color: #0f766e;
  background: #dff6f2;
}

.billing-type-pill.manual-payout,
.billing-type-pill.stripe-payout,
.billing-type-pill.review-payout {
  color: #7c2d12;
  background: #ffedd5;
}

.billing-type-pill.two-way {
  color: #4338ca;
  background: #eef2ff;
}

.statement-history-table .action-cell .text-button,
.statement-history-table .action-cell .text-link,
.statement-history-table .action-cell .muted-text {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-right: 0;
  white-space: nowrap;
}

.history-table th:nth-child(1),
.history-table td:nth-child(1) {
  width: 28%;
}

.history-table th:nth-child(2),
.history-table td:nth-child(2) {
  width: 15%;
}

.history-table th:nth-child(3),
.history-table td:nth-child(3) {
  width: 17%;
}

.history-table th:nth-child(4),
.history-table td:nth-child(4) {
  width: 14%;
}

.history-table th:nth-child(5),
.history-table td:nth-child(5) {
  width: 8%;
  text-align: right;
}

.history-table th:nth-child(6),
.history-table td:nth-child(6) {
  width: 18%;
}

th,
td {
  text-align: left;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 15px;
  line-height: 1.35;
}

th {
  color: #334255;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.action-cell {
  vertical-align: middle;
}

.action-list {
  display: flex;
  gap: 8px 12px;
  align-items: center;
  flex-wrap: wrap;
}

.history-action-list {
  flex-direction: column;
  align-items: flex-start;
}

.history-table .table-link,
.history-table .text-button,
.history-table .issue-ok {
  line-height: 1.22;
}

.table-link {
  display: inline-block;
  max-width: 100%;
  text-align: left;
  overflow-wrap: anywhere;
}

.table-subtext {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.user-primary-link {
  color: var(--ink);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  min-height: 26px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #475569;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.status-pill.success {
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.danger {
  background: var(--red-soft);
  color: var(--red);
}

.status-pill.neutral {
  background: var(--blue-soft);
  color: var(--blue);
}

.empty-state {
  display: grid;
  gap: 6px;
  justify-items: start;
  padding: 18px;
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
  font-size: 16px;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
}

.compact-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.detail-panel {
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 120px);
  overflow: auto;
  min-height: 260px;
}

.detail-panel p {
  color: var(--muted);
  line-height: 1.55;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.detail-list span {
  color: var(--muted);
}

.detail-list strong {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.detail-actions {
  margin-top: 18px;
}

.month-picker {
  width: min(100%, 190px);
}

.users-filter-label {
  width: min(100%, 280px);
}

.muted-text {
  color: var(--muted);
}

.issue-ok {
  color: var(--green) !important;
  font-size: inherit;
  font-weight: 800;
}

.monthly-reports-table .selected-report-row td,
.history-table .selected-history-row td,
.users-table .selected-user-row td {
  background: #f7f9fb;
  border-top: 2px solid var(--teal);
  border-bottom: 2px solid var(--teal);
}

.monthly-reports-table .selected-report-row td:first-child,
.history-table .selected-history-row td:first-child,
.users-table .selected-user-row td:first-child {
  border-left: 2px solid var(--teal);
  border-radius: 8px 0 0 8px;
}

.monthly-reports-table .selected-report-row td:last-child,
.history-table .selected-history-row td:last-child,
.users-table .selected-user-row td:last-child {
  border-right: 2px solid var(--teal);
  border-radius: 0 8px 8px 0;
}

.monthly-reports-table .selected-report-row:hover td,
.history-table .selected-history-row:hover td,
.users-table .selected-user-row:hover td {
  background: #f4f7fa;
}

body.modal-open {
  overflow: hidden;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.58);
}

.statement-modal,
.source-preview-modal,
.admin-modal {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 72px rgba(17, 24, 39, 0.32);
  padding: 30px;
}

.source-preview-modal {
  width: min(900px, 100%);
}

.admin-modal {
  width: min(560px, 100%);
}

.admin-form {
  display: grid;
  gap: 16px;
}

.admin-action-cell {
  vertical-align: middle;
}

.admin-action-list {
  display: grid;
  grid-template-columns: 38px 38px minmax(150px, max-content);
  align-items: center;
  gap: 8px 12px;
}

.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--blue);
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.icon-action:hover {
  background: #eef4ff;
  border-color: #bfdbfe;
}

.icon-action.danger-icon {
  color: var(--red);
}

.icon-action.danger-icon:hover {
  background: #fff1f2;
  border-color: #fecdd3;
}

.icon-action:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: #f8fafc;
  opacity: 0.58;
}

.icon-action-svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.password-reset-action {
  white-space: nowrap;
}

.admin-action-note {
  grid-column: 3;
  margin-top: -4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.danger-text {
  color: var(--red);
}

.text-button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  opacity: 0.58;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: #f4f7fb;
  color: var(--muted);
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
}

.statement-header,
.statement-section-heading,
.statement-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.statement-header {
  padding-right: 42px;
  margin-bottom: 20px;
}

.source-preview-header,
.source-preview-section-heading,
.source-preview-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.source-preview-header {
  padding-right: 42px;
  margin-bottom: 20px;
}

.source-preview-header h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.source-preview-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.source-preview-summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 14px;
}

.source-preview-summary span,
.source-preview-section-heading span {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.source-preview-summary span {
  font-size: 12px;
  text-transform: uppercase;
}

.source-preview-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.1;
}

.source-preview-section {
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.source-preview-section-heading {
  align-items: center;
  margin-bottom: 12px;
}

.source-preview-section-heading h3 {
  margin: 0;
  font-size: 18px;
}

.source-preview-table-wrap {
  width: 100%;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.03);
}

.source-preview-table {
  width: max(100%, 760px);
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.source-preview-table th,
.source-preview-table td {
  min-width: 150px;
  max-width: 300px;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.source-preview-table th:last-child,
.source-preview-table td:last-child {
  border-right: 0;
}

.source-preview-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f4f7fb;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  height: 56px;
  letter-spacing: 0;
  line-height: 1.15;
  text-transform: uppercase;
  vertical-align: middle;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
}

.source-preview-table thead .source-preview-row-number {
  background: #f4f7fb;
}

.source-preview-column-label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
}

.source-preview-table tbody tr:nth-child(even) td,
.source-preview-table tbody tr:nth-child(even) .source-preview-row-number {
  background: #fbfdff;
}

.source-preview-table tbody tr:hover td,
.source-preview-table tbody tr:hover .source-preview-row-number {
  background: #f3faf6;
}

.source-preview-row-number {
  left: 0;
  z-index: 3;
  min-width: 54px;
  width: 54px;
  max-width: 54px;
  text-align: right;
  color: var(--muted);
  background: #f8fafc;
  font-weight: 900;
}

.source-preview-table .source-preview-row-number {
  position: sticky;
}

.source-preview-empty-heading,
.source-preview-empty-cell {
  color: var(--muted);
}

.source-preview-empty {
  display: grid;
  gap: 4px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--muted);
}

.source-preview-empty strong {
  color: var(--ink);
}

.source-preview-skeleton {
  display: block;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #edf2f7, #f8fafc, #edf2f7);
  background-size: 220% 100%;
  animation: preview-loading 1.2s ease-in-out infinite;
}

@keyframes preview-loading {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: -220% 50%;
  }
}

.source-preview-actions {
  align-items: center;
  justify-content: flex-end;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.statement-header h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.statement-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

.statement-total-grid,
.statement-meta-grid {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.statement-total-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.statement-meta-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.statement-total-grid article,
.statement-meta-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 14px;
}

.statement-total-grid span,
.statement-meta-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.statement-total-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 27px;
  line-height: 1;
}

.statement-total-grid p {
  margin: 8px 0 0;
  color: var(--muted);
}

.statement-meta-grid strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.report-summary-grid {
  margin-bottom: 18px;
}

.report-meta-grid {
  margin-bottom: 24px;
}

.report-preview-section {
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.report-preview-table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.report-preview-table {
  width: 100%;
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.report-preview-table th,
.report-preview-table td {
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.report-preview-table th:last-child,
.report-preview-table td:last-child {
  border-right: 0;
}

.report-preview-table tbody tr:last-child td {
  border-bottom: 0;
}

.report-preview-table thead th {
  background: #f4f7fb;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.15;
  text-transform: uppercase;
}

.statement-payment-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.statement-payment-panel.payout-panel {
  background: #fbfdff;
}

.statement-payment-panel span,
.statement-detail-list dt {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.statement-payment-panel strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
  line-height: 1.15;
}

.statement-payment-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

.statement-payment-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.statement-detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 12px 18px;
  margin: 0;
}

.statement-detail-list div {
  min-width: 0;
}

.statement-detail-list dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.statement-lines {
  margin-top: 22px;
}

.statement-section-heading {
  align-items: center;
  margin-bottom: 10px;
}

.statement-section-heading h3 {
  margin: 0;
  font-size: 17px;
}

.statement-section-heading span {
  color: var(--muted);
  font-weight: 800;
}

.statement-line-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.statement-line-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 72px 120px 120px;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.statement-line-row:last-child {
  border-bottom: 0;
}

.statement-line-head {
  background: #f8fafc;
  color: #334255;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.statement-line-row strong,
.statement-line-row small {
  display: block;
}

.statement-line-row small {
  margin-top: 3px;
  color: var(--muted);
}

.statement-line-row span:not(:first-child) {
  text-align: right;
}

.statement-actions {
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

@container (max-width: 1240px) {
  .history-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
    max-height: none;
  }
}

@container (max-width: 980px) {
  .screen-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .history-table {
    min-width: 820px;
  }

  th,
  td {
    padding: 12px;
  }
}

@container (max-width: 760px) {
  .history-table {
    min-width: 680px;
  }

  .history-table th:nth-child(1),
  .history-table td:nth-child(1) {
    width: 30%;
  }

  .history-table th:nth-child(3),
  .history-table td:nth-child(3),
  .history-table th:nth-child(6),
  .history-table td:nth-child(6) {
    width: 20%;
  }

  .status-pill {
    white-space: normal;
  }
}

@media (max-width: 1080px) {
  .portal-layout {
    display: block;
  }

  .app-sidebar {
    position: static;
    min-height: 0;
    height: auto;
    align-self: start;
    display: grid;
    grid-template-columns: minmax(190px, auto) minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 6px 14px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .sidebar-brand {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 8px;
    padding: 0;
  }

  .sidebar-mark {
    width: 28px;
  }

  .sidebar-brand p {
    font-size: 10px;
  }

  .sidebar-brand strong {
    font-size: 12px;
  }

  .app-nav {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 0;
  }

  .app-nav-button {
    width: auto;
    min-width: 0;
    min-height: 32px;
    padding: 0 10px;
    font-size: 13px;
    text-align: center;
    white-space: nowrap;
  }

  .topbar {
    top: 0;
  }

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

@media (max-width: 900px) {
  .app-sidebar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .dashboard-grid,
  .upload-grid,
  .history-layout,
  .users-layout,
  .settings-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .screen-header,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h1 {
    max-width: 100%;
  }

  .upload-footer,
  .upload-steps {
    grid-template-columns: 1fr;
  }

  .upload-footer .primary-action {
    justify-self: stretch;
    width: 100%;
  }

  .statement-payment-panel {
    grid-template-columns: 1fr;
  }

  .statement-payment-actions {
    justify-content: flex-start;
  }

  .users-table-panel {
    height: auto;
    min-height: 0;
  }

  .users-table-scroll {
    max-height: 560px;
  }

  .statement-detail-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .signin-layout {
    padding: 0;
    place-items: stretch;
  }

  .signin-panel {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    display: grid;
    align-content: center;
  }

  .tab-panel,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .app-sidebar {
    padding: 6px 12px;
  }

  .app-nav-button {
    min-height: 32px;
    padding: 0 10px;
  }

  .dashboard-cards,
  .billing-summary {
    grid-template-columns: 1fr;
  }

  #usersMetrics {
    grid-template-columns: 1fr;
  }

  .activity-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .activity-actions {
    grid-template-columns: minmax(126px, max-content) 104px 118px;
    justify-content: flex-start;
  }

  .activity-actions.has-review-action {
    grid-template-columns: minmax(126px, max-content) minmax(150px, max-content) 104px 118px;
  }

  .preview-heading,
  .preview-actions,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .statement-modal,
  .source-preview-modal,
  .admin-modal {
    padding: 24px 18px;
  }

  .statement-header,
  .statement-section-heading,
  .statement-actions,
  .source-preview-header,
  .source-preview-section-heading,
  .source-preview-actions {
    flex-direction: column;
  }

  .source-preview-header {
    padding-right: 42px;
  }

  .source-preview-summary {
    grid-template-columns: 1fr;
  }

  .source-preview-table {
    width: max(100%, 640px);
    font-size: 13px;
  }

  .source-preview-table th,
  .source-preview-table td {
    min-width: 126px;
    padding: 10px 12px;
  }

  .source-preview-row-number {
    min-width: 48px;
    width: 48px;
    max-width: 48px;
  }

  .statement-total-grid,
  .statement-meta-grid,
  .statement-line-row {
    grid-template-columns: 1fr;
  }

  .statement-line-row span:not(:first-child) {
    text-align: left;
  }

  .preview-metrics {
    grid-template-columns: 1fr;
  }

  .preview-action-list {
    grid-template-columns: 1fr;
  }

  .compact-action,
  .compact-secondary {
    width: 100%;
  }
}
