:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --surface: #fffdfa;
  --surface-strong: #ffffff;
  --ink: #171717;
  --muted: #68635c;
  --line: #ded8cf;
  --accent: #0d766e;
  --accent-soft: #d8efea;
  --warn: #a15c05;
  --danger: #9f2d20;
  --shadow: 0 18px 50px rgba(28, 24, 18, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(13, 118, 110, 0.08), transparent 34%),
    var(--bg);
  color: var(--ink);
}

button,
select,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

select,
input {
  min-height: 36px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0 10px;
}

.app-shell {
  min-height: 100svh;
  padding: 28px;
}

.auth-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell[hidden] {
  display: none;
}

.auth-card {
  width: min(100%, 420px);
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.94);
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-card h1 {
  font-size: 34px;
}

.auth-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.two-factor-secret,
.two-factor-code-field {
  display: grid;
  gap: 8px;
}

.two-factor-qr-wrap {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.two-factor-qr-wrap canvas {
  width: 240px;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.two-factor-qr-wrap p {
  text-align: center;
  font-weight: 700;
}

.two-factor-secret {
  margin: 16px 0;
}

.two-factor-secret label,
.two-factor-code-field {
  color: var(--muted);
  font-weight: 700;
}

.workspace {
  max-width: 1560px;
  margin: 0 auto;
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  animation: rise 360ms ease both;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  line-height: 1.45;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-strip > span,
.status-strip > button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.68);
  padding: 0 12px;
  font-weight: 700;
}

.status-strip > button:hover {
  background: var(--surface-strong);
}

.warning-count-button.has-warnings {
  border-color: color-mix(in srgb, var(--warn) 38%, var(--line));
  color: #6f4305;
}

.warning-count-button.has-warnings:hover {
  border-color: var(--warn);
  background: #fff8ec;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.tab-button {
  min-height: 42px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab-button.active {
  border-color: var(--accent);
  background: var(--surface-strong);
  color: var(--accent);
  box-shadow: 0 8px 26px rgba(13, 118, 110, 0.1);
}

.tab-panel {
  animation: fade 180ms ease both;
}

.tab-panel[hidden] {
  display: none;
}

.main-grid,
.detail-grid {
  display: grid;
  gap: 16px;
}

.main-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  align-items: stretch;
}

.detail-grid {
  grid-template-columns: minmax(0, 1fr) 360px;
  margin-top: 16px;
}

.input-pane,
.summary-pane,
.table-pane,
.operations-pane,
.settings-pane,
.invoices-pane,
.balances-pane,
.problem-pane,
.users-pane,
.audit-pane,
.manager-accounts-pane,
.account-creation-pane,
.side-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.92);
  box-shadow: var(--shadow);
}

.input-pane,
.summary-pane,
.table-pane,
.operations-pane,
.settings-pane,
.invoices-pane,
.balances-pane,
.problem-pane,
.users-pane,
.audit-pane,
.manager-accounts-pane,
.account-creation-pane,
.side-pane section {
  padding: 18px;
}

.settings-pane,
.invoices-pane,
.balances-pane,
.problem-pane,
.operations-pane,
.users-pane,
.audit-pane {
  max-width: 1120px;
}

.two-factor-warning {
  width: 100%;
  min-height: 46px;
  justify-content: flex-start;
  margin-bottom: 16px;
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  background: #fff0ee;
  color: var(--danger);
  font-weight: 900;
  text-align: left;
}

.balances-table-wrap {
  max-height: none;
}

.balance-agency {
  display: grid;
  gap: 3px;
}

.balance-agency strong,
.balance-amount {
  font-weight: 900;
}

.balance-agency span,
.balance-note {
  color: var(--muted);
  font-size: 12px;
}

.balance-status {
  color: var(--muted);
}

.balance-status.error {
  color: var(--danger);
  font-weight: 800;
}

.new-accounts-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.85fr) minmax(520px, 1.15fr);
  gap: 16px;
  align-items: start;
}

.manager-account-form,
.account-creation-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.manager-account-form label,
.account-creation-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.manager-answer-field,
.manager-agency-bindings,
.manager-account-form .settings-actions,
.manager-account-form .form-status,
.creation-agency-fields,
.unsupported-agency-notice,
.login-preview,
.account-creation-form > .primary-action,
.account-creation-form > .form-status {
  grid-column: 1 / -1;
}

.manager-agency-bindings {
  margin: 2px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.manager-agency-bindings legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.manager-agency-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.manager-agency-option {
  min-height: 38px;
  display: inline-flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  padding: 0 11px;
  color: var(--ink) !important;
  text-transform: none !important;
}

.manager-agency-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent) !important;
}

.manager-agency-option input {
  width: auto;
  min-height: auto;
}

.zaleycash-agent-id {
  margin-top: 12px;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.zaleycash-agent-id[hidden] {
  display: none;
}

.form-status {
  min-height: 20px;
  font-size: 13px;
}

.form-status.error {
  color: var(--danger);
}

.manager-accounts-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.manager-account-item {
  border-bottom: 1px solid var(--line);
}

.manager-account-summary {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  padding: 10px 0;
  text-align: left;
}

.manager-account-summary:hover {
  transform: none;
}

.manager-account-summary strong {
  overflow-wrap: anywhere;
}

.manager-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.agency-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0 8px;
  font-size: 11px;
  font-weight: 900;
}

.manager-expand-icon {
  color: var(--muted);
  transition: transform 160ms ease;
}

.manager-account-item.expanded .manager-expand-icon {
  transform: rotate(180deg);
}

.manager-account-detail {
  display: none;
  padding: 2px 0 14px;
}

.manager-account-item.expanded .manager-account-detail {
  display: block;
  animation: fade 160ms ease both;
}

.manager-detail-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.manager-created-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, auto) 110px;
  gap: 10px;
  align-items: center;
  min-height: 40px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.manager-created-row span,
.manager-created-row time {
  color: var(--muted);
}

.users-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-form {
  display: grid;
  gap: 12px;
}

.user-form label,
.permission-group label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.permission-editor {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.permission-checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.permission-group {
  display: grid;
  align-content: start;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 0;
  border: 0;
  border-left: 3px solid var(--accent-soft);
  padding: 0 0 0 12px;
}

.permission-group:nth-child(2) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.permission-group:nth-child(2) h3 {
  grid-column: 1 / -1;
}

.permission-group h3 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
  font-weight: 900;
}

.permission-group label {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  min-height: 30px;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
}

.permission-group input {
  width: 18px;
  min-height: 18px;
}

.users-list,
.audit-list {
  display: grid;
  gap: 4px;
}

.audit-row {
  display: grid;
  grid-template-columns: 150px minmax(180px, 0.9fr) minmax(120px, 0.7fr) minmax(0, 1.6fr);
  gap: 12px;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(230px, auto) minmax(360px, auto);
  gap: 8px 14px;
  align-items: center;
  min-height: 66px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.user-primary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.user-primary strong,
.audit-row strong {
  overflow-wrap: anywhere;
}

.user-primary span,
.user-last-seen,
.audit-row span,
.audit-row time {
  color: var(--muted);
}

.user-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.user-actions button {
  min-height: 34px;
  padding: 0 10px;
}

.user-permissions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.user-permissions span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 6px;
  background: rgba(13, 118, 110, 0.08);
  color: var(--muted);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.user-dialog-shell {
  width: 100%;
  max-height: calc(100svh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  box-sizing: border-box;
  padding: 28px 32px;
  overflow: hidden;
}

.user-dialog {
  width: min(820px, calc(100vw - 48px));
  height: auto;
  max-width: calc(100vw - 48px);
  max-height: calc(100svh - 48px);
  margin: auto;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  padding: 0;
  overflow: hidden;
}

.topup-review-dialog.user-dialog {
  width: min(820px, calc(100vw - 48px));
  height: auto;
  max-height: calc(100svh - 48px);
}

.user-dialog-shell .topup-review-head {
  align-items: start;
  margin-bottom: 16px;
}

.user-dialog-shell .topup-review-head h2 {
  font-size: 28px;
  line-height: 1.08;
}

.user-dialog-shell .topup-review-head p:not(.eyebrow) {
  font-size: 16px;
}

.user-dialog-fields {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) 150px;
  gap: 12px;
}

.user-dialog-fields label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.user-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.user-dialog .user-form {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.user-dialog .topup-review-footer {
  position: sticky;
  bottom: 0;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 14px 0 0;
}

.user-dialog .topup-review-footer .form-status {
  min-width: 0;
  margin: 0;
}

.user-permissions .is-empty {
  background: transparent;
  padding: 0;
}

.audit-row p {
  margin: 0;
  overflow-wrap: anywhere;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 900;
}

.status-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-inactive {
  background: #f3e8e6;
  color: var(--danger);
}

.creation-agency-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
  padding: 12px;
}

.unsupported-agency-notice {
  border-left: 4px solid var(--warn);
  border-radius: 7px;
  background: #f6e7c8;
  color: #694007;
  padding: 12px;
  font-weight: 700;
}

.login-preview {
  border-block: 1px solid var(--line);
  padding: 14px 0;
}

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

.login-preview-item {
  min-width: 0;
  border-radius: 6px;
  background: #eee8df;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.account-result-list {
  max-height: min(430px, calc(100svh - 320px));
  overflow-y: auto;
  border-bottom: 1px solid var(--line);
}

.account-result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 48px;
  border-top: 1px solid var(--line);
  padding: 8px 10px;
}

.account-result-row span {
  color: var(--muted);
  font-size: 12px;
}

.account-result-row.status-approved span {
  color: #15803d;
}

.account-result-row.status-declined span,
.account-result-row.status-blocked span {
  color: var(--danger);
}

.side-pane {
  display: grid;
  align-content: start;
  gap: 0;
  overflow: hidden;
}

.side-pane section + section {
  border-top: 1px solid var(--line);
}

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

.pane-head.compact {
  align-items: center;
}

.mini-badge {
  min-width: 28px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 900;
}

.actions {
  display: flex;
  gap: 8px;
}

textarea {
  width: 100%;
  min-height: 430px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141414;
  color: #f8f6f1;
  padding: 18px;
  line-height: 1.5;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 118, 110, 0.18);
}

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

.total-box {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
  padding: 14px;
}

.total-box span {
  color: var(--accent);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 12px;
}

.total-box strong {
  color: var(--accent);
  font-size: 28px;
  line-height: 1;
  white-space: nowrap;
}

.agency-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  animation: fade 220ms ease both;
}

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

.agency-name {
  font-weight: 800;
}

.agency-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.agency-amount {
  font-size: 24px;
  font-weight: 900;
  color: var(--accent);
  text-align: right;
  white-space: nowrap;
}

.table-wrap {
  max-height: 390px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eee8df;
  color: #4c463f;
  font-size: 12px;
  text-transform: uppercase;
}

.table-sort-button {
  min-height: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  padding: 3px 4px;
  margin: -3px -4px;
  font-size: inherit;
  font-weight: 800;
  text-transform: inherit;
}

.table-sort-button:hover {
  border-color: transparent;
  background: rgba(13, 118, 110, 0.09);
  color: var(--accent);
  transform: none;
}

.table-sort-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.table-sort-button.active {
  color: var(--accent);
}

.sort-indicator {
  min-width: 11px;
  font-size: 13px;
  line-height: 1;
  text-align: center;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: var(--accent-soft);
}

.workflow {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.workflow li {
  min-height: 34px;
  display: flex;
  align-items: center;
  border-left: 3px solid var(--line);
  padding-left: 12px;
  color: var(--muted);
}

.workflow .done {
  border-left-color: var(--accent);
  color: var(--ink);
  font-weight: 800;
}

.warnings {
  min-height: 90px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.warnings li {
  border-left: 3px solid var(--warn);
  padding-left: 12px;
  color: #5d3b08;
  line-height: 1.35;
}

.warnings-dialog {
  width: min(720px, calc(100vw - 32px));
}

.warnings-dialog-list {
  min-height: 0;
  max-height: min(56svh, 560px);
  margin: 0;
  overflow-y: auto;
  padding: 2px 8px 2px 0;
}

.warnings-dialog-list li {
  background: #fffaf1;
  border-radius: 0 7px 7px 0;
  padding-block: 11px;
  padding-right: 12px;
}

.review-list,
.rules-list,
.cut-rules-list,
.cpl-list {
  display: grid;
  gap: 12px;
}

.review-item,
.rule-item,
.cut-rule-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.review-item p {
  margin-top: 8px;
  color: var(--ink);
  font-weight: 800;
}

.review-item small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
}

.review-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.review-title span,
.rule-item span {
  color: var(--muted);
  font-size: 13px;
}

.review-controls {
  display: grid;
  grid-template-columns: 1fr 0.72fr auto;
  gap: 8px;
  align-items: end;
  margin-top: 12px;
}

.review-controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.severity-high {
  border-left-color: var(--danger);
}

.severity-medium {
  border-left-color: var(--warn);
}

.severity-low {
  border-left-color: #7c6f59;
}

.severity-info {
  border-left-color: var(--accent);
}

.rule-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.rule-item span,
.cut-rule-item span {
  grid-column: 1 / -1;
}

.cut-rule-form {
  display: grid;
  grid-template-columns: 1fr 0.82fr 0.72fr;
  gap: 8px;
  align-items: end;
}

.cut-rule-form label,
.settings-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.cut-rule-form button {
  grid-column: 1 / -1;
}

.cut-rules-list {
  margin-top: 12px;
}

.settings-form {
  display: grid;
  gap: 9px;
}

.settings-pane .settings-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-pane .advanced-settings,
.settings-pane .agency-specific-settings,
.settings-pane .settings-actions {
  grid-column: 1 / -1;
}

.agency-specific-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
  padding: 12px;
}

.agency-specific-settings[hidden] {
  display: none;
}

.agency-specific-settings-head {
  grid-column: 1 / -1;
}

.agency-specific-settings-head strong,
.agency-specific-settings-head span {
  display: block;
}

.agency-specific-settings-head span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.invoice-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.invoice-card {
  display: grid;
  align-content: start;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 16px;
}

.invoice-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.invoice-provider {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.invoice-request-total {
  min-height: 104px;
  display: grid;
  justify-items: start;
  align-content: center;
  gap: 4px;
  border-color: var(--accent);
  background: var(--accent-soft);
  text-align: left;
}

.invoice-request-total span,
.invoice-card label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.invoice-request-total strong {
  color: var(--accent);
  font-size: 26px;
}

.invoice-request-total small {
  color: var(--muted);
}

.invoice-card label {
  display: grid;
  gap: 6px;
}

.invoice-result {
  min-height: 38px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.invoice-result.error {
  color: var(--danger);
}

.invoice-result a {
  color: var(--accent);
  font-weight: 800;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-form .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.settings-form .checkbox-label input {
  width: auto;
  min-height: auto;
}

.advanced-settings {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
  padding: 10px;
}

.advanced-settings summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 900;
}

.advanced-settings label {
  margin-top: 9px;
}

.saved-agencies-section {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

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

.saved-agency-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.saved-agency-item.selected {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.saved-agency-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.cut-rule-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.amount-cut {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.cpl-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 11px 12px;
}

.cpl-item span {
  color: var(--danger);
  font-weight: 900;
}

.cpl-analytics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.cpl-analytics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px;
}

.cpl-analytics span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.cpl-analytics strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  line-height: 1;
}

.automation-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.agency-topup-actions {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.agency-topup-actions button {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.agency-topup-actions small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.automation-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.automation-summary div,
.automation-stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px;
}

.automation-summary span,
.automation-stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.automation-summary strong,
.automation-stat strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
  line-height: 1;
}

.automation-stat {
  min-height: 68px;
  display: block;
  text-align: left;
}

.automation-stat small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.automation-queue:hover,
.automation-queue:focus-visible {
  border-color: #a16207;
  background: #fffbeb;
}

.automation-success:hover,
.automation-success:focus-visible {
  border-color: #15803d;
  background: #f0fdf4;
}

.automation-errors:hover,
.automation-errors:focus-visible {
  border-color: var(--danger);
  background: #fff8f6;
}

.automation-errors small {
  color: var(--danger);
}

.current-operation {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.current-operation span {
  color: var(--muted);
  font-size: 13px;
}

.current-operation.error {
  border-left-color: var(--danger);
  color: var(--danger);
}

.topup-review-dialog {
  width: min(680px, calc(100vw - 32px));
  height: min(860px, calc(100svh - 32px));
  max-height: calc(100svh - 32px);
  margin: auto;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
  padding: 0;
  box-shadow: 0 30px 90px rgba(23, 23, 23, 0.26);
}

.topup-review-dialog::backdrop {
  background: rgba(23, 23, 23, 0.52);
  backdrop-filter: blur(3px);
}

.topup-review-shell {
  display: grid;
  grid-template-rows: auto auto auto auto auto minmax(0, 1fr) auto;
  height: 100%;
  padding: 22px;
  animation: rise 180ms ease both;
}

.topup-review-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
}

.topup-review-head h2 {
  font-size: 24px;
}

.topup-review-head p:last-child {
  margin-top: 7px;
}

.dialog-close {
  min-width: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.topup-review-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-block: 1px solid var(--line);
}

.topup-review-summary div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
}

.topup-review-summary div + div {
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.topup-review-summary div:first-child {
  padding-right: 18px;
}

.topup-review-summary span,
.topup-review-columns {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.topup-review-summary strong {
  color: var(--accent);
  font-size: 20px;
}

.topup-review-columns,
.topup-review-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
}

.topup-review-columns {
  padding: 14px 12px 8px;
}

.topup-review-columns span:last-child,
.topup-review-row span {
  text-align: right;
}

.topup-review-list {
  max-height: clamp(120px, calc(100svh - 430px), calc(10 * 48px + 2px));
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-block: 1px solid var(--line);
  scrollbar-gutter: stable;
}

.topup-review-row {
  min-height: 48px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.topup-review-row:last-child {
  border-bottom: 0;
}

.topup-review-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topup-review-row span {
  color: var(--accent);
  font-weight: 900;
  white-space: nowrap;
}

.topup-balance-preview {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(180px, 0.8fr);
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.topup-balance-preview.compact {
  grid-template-columns: 1fr minmax(180px, 0.8fr);
}

.topup-balance-preview[hidden] {
  display: none;
}

.topup-balance-preview div {
  display: grid;
  gap: 4px;
}

.topup-balance-preview span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.topup-balance-preview strong {
  color: var(--accent);
  font-size: 16px;
  font-weight: 900;
}

.topup-balance-preview p {
  justify-self: end;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}

.topup-balance-preview p.ok {
  color: var(--accent);
}

.topup-balance-preview p.warn {
  color: #9a6a13;
}

.topup-balance-preview p.error {
  color: var(--danger);
}

.topup-review-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 0 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.topup-review-option[hidden] {
  display: none;
}

.topup-review-option input {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  accent-color: var(--accent);
}

.topup-review-footer {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-top: 14px;
}

.topup-review-footer p {
  max-width: 380px;
  font-size: 13px;
}

.topup-review-footer p.error {
  color: var(--danger);
}

.errors-dialog {
  width: min(940px, calc(100vw - 32px));
}

.error-list-columns,
.topup-error-row {
  display: grid;
  grid-template-columns: 150px minmax(180px, 1.2fr) minmax(130px, 0.8fr) 110px;
  align-items: center;
  gap: 0;
}

.error-list-columns {
  border-block: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.error-list-columns span,
.topup-error-row > * {
  min-width: 0;
  padding: 10px 12px;
}

.error-list-columns > :not(:first-child),
.topup-error-row > :not(:first-child) {
  border-left: 1px solid var(--line);
}

.topup-errors-list {
  min-height: 80px;
  max-height: min(520px, calc(100svh - 290px));
  overflow: auto;
  border-bottom: 1px solid var(--line);
}

.topup-error-row {
  min-width: 680px;
  border-bottom: 1px solid var(--line);
}

.topup-error-row:last-child {
  border-bottom: 0;
}

.topup-error-row time {
  color: var(--muted);
  font-size: 13px;
}

.topup-error-row strong {
  overflow-wrap: anywhere;
}

.topup-error-row span:last-child {
  font-weight: 900;
  white-space: nowrap;
}

.status-list-errors .topup-error-row span:last-child {
  color: var(--danger);
}

.status-list-success .topup-error-row span:last-child {
  color: #15803d;
}

.status-list-queue .topup-error-row span:last-child {
  color: #a16207;
}

.topup-errors-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
}

.topup-errors-footer > div {
  display: flex;
  gap: 8px;
}

.topup-errors-footer p {
  font-size: 13px;
}

.primary-action {
  min-width: 150px;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.primary-action:hover {
  background: #095e58;
}

.mode-dry {
  background: #f6e7c8;
  color: #7b4b00;
}

.mode-live {
  background: var(--accent-soft);
  color: var(--accent);
}

.mode-offline {
  background: #ece7df;
  color: var(--muted);
}

.operations-timeline {
  border-top: 1px solid var(--line);
}

.operations-toolbar {
  position: relative;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 4px 0 14px;
}

.operations-filters {
  display: flex;
  align-items: center;
  gap: 10px;
}

.operations-status-filter {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  padding: 0 7px 0 13px;
}

.operations-status-filter span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.operations-status-filter select {
  width: auto;
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0 26px 0 0;
  font-size: 14px;
  font-weight: 800;
}

.operations-status-filter select:focus {
  outline: none;
}

.operations-status-filter:focus-within {
  border-color: var(--accent);
}

.period-filter {
  position: relative;
}

.period-filter summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  padding: 0 13px;
  cursor: pointer;
  list-style: none;
}

.period-filter summary::-webkit-details-marker {
  display: none;
}

.period-filter summary::after {
  content: "▾";
  color: var(--muted);
  font-size: 12px;
}

.period-filter[open] summary {
  border-color: var(--accent);
}

.period-filter summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.period-filter summary strong {
  color: var(--accent);
  font-size: 14px;
}

.period-filter-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  width: min(560px, calc(100vw - 64px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: 0 22px 60px rgba(28, 24, 18, 0.18);
  padding: 16px;
}

.period-date-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.period-date-fields label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.period-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px 12px;
  margin-top: 14px;
  border-block: 1px solid var(--line);
  padding: 10px 0;
}

.period-presets button {
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  text-align: left;
  font-weight: 700;
}

.period-presets button:hover {
  transform: none;
  text-decoration: underline;
}

.period-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.operations-result-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.operations-toolbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.operations-delete-status {
  min-height: 18px;
  margin: -7px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.danger-action {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  background: #fff8f6;
  color: var(--danger);
  font-weight: 800;
}

.danger-action:hover:not(:disabled) {
  border-color: var(--danger);
  background: #fce8e4;
}

.delete-operations-dialog {
  width: min(560px, calc(100vw - 32px));
}

.delete-operations-warning {
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  background: #fff8f6;
  color: var(--danger);
  padding: 14px;
  line-height: 1.5;
}

.delete-operations-actions {
  display: flex;
  gap: 8px;
}

.operations-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  margin-top: 16px;
}

.operations-pagination button {
  min-width: 38px;
  padding: 0 9px;
}

.operations-pagination button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.pagination-ellipsis {
  min-width: 24px;
  color: var(--muted);
  text-align: center;
}

.operation-row {
  display: grid;
  grid-template-columns: 150px minmax(130px, 0.8fr) minmax(180px, 1.2fr) 120px 110px;
  align-items: center;
  gap: 0;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  animation: fade 180ms ease both;
}

.operation-row > time,
.operation-row > span,
.operation-row > strong {
  min-width: 0;
  padding: 10px 14px;
  overflow-wrap: anywhere;
}

.operation-row > :not(:first-child) {
  border-left: 1px solid var(--line);
}

.operation-row time {
  color: var(--muted);
  font-size: 13px;
}

.operation-amount {
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}

.operation-status-wrap {
  position: relative;
}

.operation-status {
  display: inline-block;
  font-size: 12px;
  font-weight: 900;
  text-transform: lowercase;
}

.status-text-approved {
  color: #15803d;
}

.status-text-declined,
.status-text-blocked {
  color: var(--danger);
}

.status-text-pending,
.status-text-accepted {
  color: #a16207;
}

.has-tooltip {
  cursor: help;
  text-decoration: underline dotted currentColor;
  text-underline-offset: 3px;
}

.operation-tooltip {
  position: absolute;
  z-index: 10;
  right: 12px;
  bottom: calc(100% - 4px);
  width: min(320px, 70vw);
  border-radius: 7px;
  background: #292621;
  color: #fff;
  padding: 9px 11px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
}

.has-tooltip:hover + .operation-tooltip,
.has-tooltip:focus + .operation-tooltip {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 820px) {
  .period-filter-popover {
    width: min(460px, calc(100vw - 32px));
  }

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

  .operation-row {
    grid-template-columns: 130px minmax(120px, 0.8fr) minmax(170px, 1.2fr) 110px 100px;
    min-width: 720px;
  }

  .operations-timeline {
    overflow-x: auto;
  }
}

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

.invalid {
  color: var(--danger);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 1080px) {
  .main-grid,
  .detail-grid,
  .new-accounts-layout,
  .user-dialog-fields,
  .permission-checklist {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    margin-bottom: 24px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .pane-head {
    display: grid;
    justify-content: stretch;
  }

  .operations-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .operations-filters {
    align-items: stretch;
    flex-direction: column;
  }

  .operations-status-filter {
    justify-content: space-between;
  }

  .operations-toolbar-meta {
    justify-content: space-between;
  }

  .period-filter summary {
    justify-content: space-between;
  }

  .period-filter-popover {
    left: -1px;
    width: calc(100vw - 34px);
  }

  .period-date-fields,
  .period-presets {
    grid-template-columns: 1fr;
  }

  .status-strip {
    justify-content: stretch;
  }

  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .status-strip span,
  button {
    justify-content: center;
  }

  .settings-pane .settings-form {
    grid-template-columns: 1fr;
  }

  .manager-account-form,
  .account-creation-form,
  .creation-agency-fields {
    grid-template-columns: 1fr;
  }

  .agency-specific-settings {
    grid-template-columns: 1fr;
  }

  .invoice-cards {
    grid-template-columns: 1fr;
  }

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

  .manager-account-summary {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .manager-badges {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .manager-created-row {
    grid-template-columns: 1fr;
    gap: 3px;
    padding: 9px 0;
  }

  .user-row,
  .audit-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .user-meta {
    justify-content: flex-start;
  }

  .users-head-actions,
  .user-actions,
  .user-dialog-actions {
    justify-content: stretch;
  }

  .users-head-actions,
  .user-actions,
  .user-dialog-actions {
    display: grid;
  }

  textarea {
    min-height: 330px;
  }

  .topup-review-shell {
    padding: 16px;
  }

  .topup-review-summary div {
    display: grid;
    gap: 4px;
  }

  .topup-review-footer {
    display: grid;
  }

  .topup-errors-footer,
  .topup-errors-footer > div {
    display: grid;
  }

  .topup-errors-footer button {
    width: 100%;
  }

  .topup-review-footer .primary-action {
    width: 100%;
  }
}
