:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d7dee8;
  --line-soft: #e8edf3;
  --text: #16202a;
  --muted: #647184;
  --accent: #1f5fbf;
  --accent-dark: #164a96;
  --success-bg: #e9f7ef;
  --success-text: #146c43;
  --warn-bg: #fff6db;
  --warn-text: #8a5a00;
  --danger-bg: #fdecec;
  --danger-text: #a12828;
  --info-bg: #eef5ff;
  --info-text: #1f4d8f;
  --shadow: 0 14px 34px rgb(20 35 55 / 9%);
}

* {
  letter-spacing: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.app-shell {
  max-width: 1320px;
}

.app-main {
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  padding-top: 20px;
}

.app-nav {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgb(20 35 55 / 2%);
}

.app-brand {
  align-items: center;
  display: inline-flex;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: var(--accent);
  border-radius: 7px;
  color: #fff;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  line-height: 1;
  min-width: 44px;
  padding: 0 8px;
}

.brand-title,
.brand-subtitle {
  display: block;
  line-height: 1.15;
}

.brand-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 750;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
}

.navbar-brand {
  margin-right: 24px;
}

.navbar-toggler {
  border-color: var(--line);
  border-radius: 8px;
  min-height: 42px;
  min-width: 46px;
}

.navbar-nav .nav-link {
  border-radius: 7px;
  color: #334155;
  font-weight: 650;
  padding-left: 10px;
  padding-right: 10px;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus {
  background: #eef3f8;
  color: var(--text);
}

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

.user-chip {
  background: #f1f5f9;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: #465568;
  font-size: 12px;
  font-weight: 650;
  padding: 5px 10px;
  white-space: nowrap;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 24px;
  font-weight: 780;
  line-height: 1.22;
  margin-bottom: 0;
}

h2 {
  font-size: 16px;
  font-weight: 750;
  line-height: 1.3;
  margin-bottom: 12px;
}

.page-head {
  align-items: flex-end;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.page-head p,
.muted {
  color: var(--muted);
}

.page-head p {
  margin: 6px 0 0;
}

.filter-panel,
.panel,
.login-panel,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filter-panel {
  margin-bottom: 14px;
  padding: 14px;
}

.filter-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 2fr) repeat(5, minmax(120px, 1fr));
}

.filter-grid label,
.stack-form label,
.field-group {
  display: grid;
  gap: 6px;
}

.filter-grid span,
.field-group label,
.stack-form label,
.stack-form p label {
  color: #465568;
  font-size: 12px;
  font-weight: 700;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.app-btn {
  border-radius: 7px;
  font-weight: 700;
  min-height: 34px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.form-control,
.form-select,
.login-form input,
.stack-form input[type="text"],
.stack-form input[type="password"],
.stack-form input[type="email"],
.stack-form input[type="number"],
.stack-form textarea,
.stack-form select {
  border-color: #b9c3d0;
  border-radius: 7px;
  color: var(--text);
  width: 100%;
}

.form-control:focus,
.form-select:focus,
.login-form input:focus,
.stack-form input:focus,
.stack-form textarea:focus,
.stack-form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(31 95 191 / 14%);
}

.table-wrap {
  overflow-x: auto;
}

.app-table {
  margin: 0;
  min-width: 760px;
}

.app-table th {
  background: #f8fafc;
  border-bottom-color: var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding-bottom: 10px;
  padding-top: 10px;
  white-space: nowrap;
}

.app-table td {
  border-color: var(--line-soft);
  padding-bottom: 10px;
  padding-top: 10px;
  vertical-align: top;
}

.row-title {
  font-weight: 750;
}

.amount-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  white-space: nowrap;
}

.status-pill {
  background: var(--info-bg);
  border: 1px solid #c9dbf3;
  border-radius: 999px;
  color: var(--info-text);
  display: inline-flex;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
  padding: 4px 9px;
  white-space: nowrap;
}

.status-deposited {
  background: var(--success-bg);
  border-color: #b8e0c8;
  color: var(--success-text);
}

.status-pending_claim,
.status-reminder,
.status-needs_review,
.status-fraud_review {
  background: var(--warn-bg);
  border-color: #f1d891;
  color: var(--warn-text);
}

.status-cancelled,
.status-failed,
.status-expired {
  background: var(--danger-bg);
  border-color: #efb8b8;
  color: var(--danger-text);
}

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

.panel {
  padding: 16px;
}

.detail-list {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  margin: 0;
  row-gap: 9px;
}

.detail-list dt {
  color: var(--muted);
  font-weight: 750;
}

.detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.payment-detail-head .app-btn,
.panel-title-row .app-btn {
  flex: 0 0 auto;
}

.panel-title-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-title-row h2 {
  margin-bottom: 0;
}

.raw-email-panel {
  overflow: hidden;
}

.raw-email-meta {
  display: grid;
  gap: 10px 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
}

.raw-email-meta-item {
  background: #f8fafc;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  min-width: 0;
  padding: 9px 10px;
}

.raw-email-meta-item span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.raw-email-meta-item strong {
  color: var(--text);
  display: block;
  font-size: 13px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.raw-email-body {
  background: #f8fafc;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
  max-height: 520px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-row {
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.login-layout {
  align-items: center;
  display: grid;
  min-height: calc(100svh - 96px);
  padding: 28px 0;
}

.login-panel {
  box-shadow: var(--shadow);
  margin: 0 auto;
  max-width: 430px;
  padding: 22px;
  width: min(100%, 430px);
}

.login-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.login-mark {
  height: 42px;
  min-width: 52px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  margin-bottom: 4px;
}

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

.stack-form p {
  display: grid;
  gap: 6px;
  margin: 0;
}

.login-form input {
  font-size: 16px;
  min-height: 44px;
  padding: 9px 11px;
}

.login-submit {
  margin-top: 4px;
  min-height: 42px;
  width: 100%;
}

@media (max-width: 1040px) {
  .filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  body {
    font-size: 14px;
  }

  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .app-main {
    padding-top: 14px;
  }

  .app-brand {
    gap: 8px;
  }

  .brand-mark {
    height: 32px;
    min-width: 42px;
  }

  .brand-title {
    font-size: 14px;
  }

  .brand-subtitle {
    font-size: 11px;
  }

  .navbar-collapse {
    border-top: 1px solid var(--line-soft);
    margin-top: 10px;
    padding-top: 8px;
  }

  .navbar-nav {
    gap: 2px;
  }

  .nav-user {
    align-items: stretch;
    border-top: 1px solid var(--line-soft);
    flex-direction: column;
    margin-top: 8px;
    padding-top: 10px;
  }

  .nav-user form,
  .nav-user button {
    width: 100%;
  }

  h1 {
    font-size: 22px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .filter-panel,
  .panel,
  .login-panel {
    padding: 14px;
  }

  .filter-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

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

  .filter-actions .btn {
    width: 100%;
  }

  .table-wrap {
    background: transparent;
    border: 0;
    border-radius: 0;
    overflow: visible;
  }

  .app-table {
    border-collapse: separate;
    border-spacing: 0 10px;
    min-width: 0;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }

  .responsive-table tr {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 6px 18px rgb(20 35 55 / 5%);
    overflow: hidden;
  }

  .responsive-table td {
    border-bottom: 1px solid var(--line-soft);
    border-top: 0;
    display: grid;
    gap: 5px;
    padding: 10px 12px;
  }

  .responsive-table td:last-child {
    border-bottom: 0;
  }

  .responsive-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 11px;
    font-weight: 800;
  }

  .responsive-table .empty-row::before {
    content: "";
  }

  .detail-list {
    grid-template-columns: 1fr;
    row-gap: 4px;
  }

  .detail-list dd {
    margin-bottom: 8px;
  }

  .payment-detail-head .app-btn,
  .panel-title-row .app-btn {
    width: 100%;
  }

  .panel-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .raw-email-meta {
    grid-template-columns: 1fr;
  }

  .raw-email-body {
    max-height: 60svh;
    padding: 12px;
  }

  .login-layout {
    align-items: start;
    min-height: auto;
    padding-top: 18px;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .filter-actions {
    grid-template-columns: 1fr;
  }

  .login-panel {
    border-radius: 8px;
    box-shadow: 0 8px 22px rgb(20 35 55 / 7%);
  }
}
