:root {
  --paypal-blue: #003087;
  --paypal-light-blue: #0070e0;
  --bg: #f5f8fc;
  --panel: #ffffff;
  --border: #e5edf7;
  --text: #102a43;
  --muted: #627d98;
  --success: #0f9d58;
  --warning: #c77700;
  --danger: #d93025;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
}

.sidebar {
  background: linear-gradient(180deg, var(--paypal-blue), #001f66);
  color: #fff;
  padding: 20px 12px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: var(--paypal-light-blue);
}

.brand-title {
  margin: 0;
  font-weight: 700;
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.75;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: #fff;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.menu-group-title:hover {
  background: rgba(255, 255, 255, 0.08);
}

.menu-caret {
  font-size: 12px;
  opacity: 0.8;
  transition: transform 0.15s ease;
}

.menu-group:not(.open) .menu-caret {
  transform: rotate(-90deg);
}

.menu-sub {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding-left: 10px;
}

.menu-group.open .menu-sub {
  display: flex;
}

.menu-item {
  border: 1px solid transparent;
  background: transparent;
  color: #fff;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}

.menu-sub-item {
  padding: 9px 12px 9px 16px;
  font-size: 13px;
  opacity: 0.92;
}

.menu-item.active {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
  opacity: 1;
}

a.menu-link {
  display: block;
  text-decoration: none;
}

.menu-item.active.menu-link {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}

.content {
  padding: 20px;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
}

.status-bar {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  background: #eef6ff;
  color: #1f4a7c;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.status-bar.error {
  background: #fff3f2;
  border-color: #f6d3cf;
  color: #9c2f27;
}

.status-bar.success {
  background: #edf9f1;
  border-color: #ccead6;
  color: #1f6c3d;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 100%;
}

.fixed-period {
  font-size: 13px;
  color: var(--muted);
}

label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  color: var(--text);
}

.secondary-btn,
.primary-btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
}

.secondary-btn {
  color: var(--paypal-blue);
  background: #e8f1ff;
}

.primary-btn {
  color: #fff;
  background: linear-gradient(90deg, var(--paypal-blue), var(--paypal-light-blue));
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  min-width: 0;
}

.metric-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.metric-title {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.metric-value {
  margin: 8px 0 0;
  font-size: 24px;
  font-weight: 700;
}

.metric-value.rate {
  font-size: 21px;
}

.metric-split {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.metric-risk-line {
  margin-top: 10px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.metric-risk-rate {
  font-size: 24px;
  font-weight: 700;
}

.metric-risk-rate.refund,
.metric-count-btn.refund,
.metric-count-btn.transaction {
  color: var(--text);
}

.metric-risk-rate.chargeback,
.metric-risk-rate.fraud,
.metric-count-btn.chargeback,
.metric-count-btn.fraud {
  color: var(--text);
}

.metric-count-btn {
  border: 0;
  background: transparent;
  color: var(--paypal-blue);
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
}

.metric-count-btn:hover {
  color: #001f66;
}

.metric-value.refund {
  color: var(--text);
}

.metric-value.chargeback,
.metric-value.fraud {
  color: var(--text);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  min-width: 0;
  max-width: 100%;
}

.panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.detail-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

#detailPageInfo {
  font-size: 13px;
  color: var(--muted);
}

.table-wrap {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.table-wrap table {
  width: max-content;
  min-width: 100%;
  max-width: none;
}

.merchant-meta {
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}

.risk-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
}

.merchant-meta .risk-badge {
  margin-left: 8px;
}

.risk-badge.low {
  background: #edf9f1;
  color: #1f6c3d;
}

.risk-badge.medium {
  background: #fff7e8;
  color: #9a6700;
}

.risk-badge.high {
  background: #fff3f2;
  color: #9c2f27;
}

.merchant-warning {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #b42318;
  background: #fee4e2;
  border: 1px solid #fecdca;
  vertical-align: middle;
}

.merchant-alert {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.merchant-alert.good {
  background: #edf9f1;
  border-color: #ccead6;
  color: #1f6c3d;
}

.merchant-alert.bad {
  background: #fff3f2;
  border-color: #f6d3cf;
  color: #9c2f27;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
  vertical-align: top;
}

th {
  font-size: 12px;
  color: var(--muted);
  background: #f8fbff;
}

/* Allow wrapping in text-heavy columns without blowing page width */
td.wrap-cell,
th.wrap-cell {
  white-space: normal;
  word-break: break-word;
}

tbody tr:hover {
  background: #f3f8ff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.hidden {
  display: none;
}

.login-body {
  background: radial-gradient(circle at top right, #e3eeff, #f5f8fc 48%);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 18px 44px rgba(16, 42, 67, 0.12);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.login-brand .brand-subtitle {
  color: var(--muted);
  opacity: 1;
}

.login-title {
  margin: 0;
  font-size: 24px;
}

.login-desc {
  margin: 8px 0 20px;
  color: var(--muted);
}

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

.field {
  display: grid;
  gap: 6px;
}

.field input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.login-message {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.login-message.error {
  color: var(--danger);
}

.site-footer {
  margin-top: 24px;
  padding: 12px 0 4px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content .site-footer {
  margin-top: auto;
  padding-top: 24px;
}

.login-page {
  grid-template-rows: 1fr auto;
}

.login-page .site-footer {
  margin-top: 0;
}

/* MacBook Air 14" / laptop widths */
@media (max-width: 1440px) {
  .layout {
    grid-template-columns: 200px minmax(0, 1fr);
  }

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

  .metric-value {
    font-size: 20px;
  }

  .metric-value.rate {
    font-size: 18px;
  }
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 180px minmax(0, 1fr);
  }

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

  .content {
    padding: 16px;
  }

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

  .menu-group-title,
  .menu-item {
    font-size: 13px;
    padding: 8px 10px;
  }
}

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

  .sidebar {
    padding: 12px;
  }

  .content {
    padding: 14px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 20px;
  }
}
