:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
  --bg: #ededed;
  --card: #ffffff;
  --text: #333333;
  --muted: #999999;
  --line: #e5e5e5;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  --primary: #07c160;
  --primary-dark: #06ad56;
  --soft: #f0fff6;
  --danger: #fa5151;
  --danger-dark: #d83b3b;
  --success: #07c160;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 64px 16px 66px;
}

a {
  color: inherit;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: #ffffff;
  color: var(--text);
  font-size: 15px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
}

form {
  display: grid;
  gap: 12px;
}

code {
  display: inline-block;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 8px;
  background: #f2f4f7;
  overflow-wrap: anywhere;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

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

th {
  background: #f7f7f7;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

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

.app-shell {
  min-height: 100vh;
}

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.top-bar__inner {
  position: relative;
  width: min(1120px, 100%);
  min-height: 48px;
  margin: 0 auto;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.top-bar__account {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}

.top-bar__user {
  max-width: 112px;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-form {
  display: inline-flex;
  gap: 0;
}

.logout-button {
  min-height: 44px;
  width: auto;
  padding-inline: 12px;
}

.top-bar__title {
  margin: 0;
  max-width: calc(100% - 190px);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.top-bar__subtitle {
  display: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.bottom-bar__inner {
  width: min(1120px, 100%);
  margin: 0 auto;
  min-height: 50px;
  padding: 3px 8px;
  display: flex;
  gap: 0;
  justify-content: space-around;
  overflow-x: auto;
}

.bottom-bar a {
  position: relative;
  min-width: 56px;
  min-height: 46px;
  flex: 1 0 auto;
  flex-direction: column;
  gap: 2px;
  border: 0;
  border-radius: 0;
  padding: 4px 6px;
  color: #666666;
  font-size: 12px;
  font-weight: 400;
  background: transparent;
}

.bottom-bar a::before {
  content: "";
  width: 18px;
  height: 18px;
  display: block;
  border: 2px solid currentColor;
  border-radius: 5px;
  opacity: 0.92;
}

.bottom-bar a[href$="/merchant"]::before,
.bottom-bar a[href$="/admin"]::before {
  border-radius: 50% 50% 5px 5px;
}

.bottom-bar a[href*="book"]::before,
.bottom-bar a[href*="transactions"]::before {
  border-radius: 4px;
  box-shadow: inset 0 -5px 0 currentColor;
}

.bottom-bar a[href*="settings"]::before,
.bottom-bar a[href*="credential"]::before {
  border-radius: 50%;
}

.bottom-bar a[href*="invitations"]::before {
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px #ffffff;
  background: currentColor;
}

.bottom-bar a.is-active {
  color: var(--primary);
  background: transparent;
  font-weight: 600;
}

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

.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 15px;
}

.card h1,
.card h2,
.card h3 {
  margin-top: 0;
}

.card-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 700;
}

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

.alert {
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff5f5;
  color: #c53030;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
}

.notice {
  border: 1px solid #c8f3dc;
  border-radius: 8px;
  background: var(--soft);
  color: #148848;
  padding: 10px 12px;
  font-size: 13px;
}

.notice--hidden {
  display: none;
}

.toast {
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #f0fff6;
  color: #148848;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
}

.checkbox-line {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 15px;
}

.checkbox-line--compact {
  min-height: 28px;
  font-size: 13px;
  color: var(--muted);
}

.checkbox-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.btn,
button,
.admin-nav a,
.merchant-nav a,
.button-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 20px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
  box-shadow: none;
}

.btn:hover,
button:hover,
.admin-nav a:hover,
.merchant-nav a:hover,
.button-link:hover {
  background: var(--primary-dark);
}

.btn:active,
button:active,
.admin-nav a:active,
.merchant-nav a:active,
.button-link:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: none;
}

.btn--secondary,
.top-bar a {
  border-color: var(--line);
  background: #ffffff;
  color: var(--text);
  box-shadow: none;
}

.btn--secondary:hover,
.top-bar a:hover {
  background: #f7f7f7;
}

.btn--danger,
button.danger {
  background: var(--danger);
  box-shadow: none;
}

.btn--danger:hover,
button.danger:hover {
  background: var(--danger-dark);
}

.admin-nav,
.merchant-nav,
.action-row,
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.bottom-bar .bottom-bar__inner a {
  min-width: 56px;
  min-height: 46px;
  flex: 1 0 auto;
  flex-direction: column;
  gap: 2px;
  border: 0;
  border-radius: 0;
  padding: 4px 6px;
  color: #666666;
  font-size: 12px;
  font-weight: 400;
  background: transparent;
  box-shadow: none;
}

.bottom-bar .bottom-bar__inner a:hover,
.bottom-bar .bottom-bar__inner a:active {
  background: transparent;
}

.bottom-bar .bottom-bar__inner a.is-active {
  color: var(--primary);
  font-weight: 600;
}

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

.quick-action {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: none;
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.quick-action--disabled,
.quick-action--disabled:hover {
  border-color: #cbd5e1;
  background: #cbd5e1;
  color: #64748b;
  cursor: not-allowed;
  box-shadow: none;
}

.quick-action:hover,
.quick-action:active {
  background: var(--primary-dark);
}

.quick-action:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: none;
}

.quick-action--primary {
  background: var(--primary);
}

.badge {
  min-width: 20px;
  min-height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #ffffff;
  color: var(--primary);
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
}

.badge--empty {
  display: none;
}

.filter-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}

.tab-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.btn--disabled,
.btn--disabled:hover {
  pointer-events: none;
  border-color: #cbd5e1;
  background: #e2e8f0;
  color: #64748b;
  box-shadow: none;
}

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

.amount {
  font-weight: 900;
}

.amount--positive {
  color: var(--success);
}

.amount--negative {
  color: var(--danger);
}

.dashboard-card-grid,
.book-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.metric-panel {
  display: grid;
  gap: 10px;
  align-content: start;
}

.metric-panel--turnover {
  background: #f5f5f5;
}

.metric-panel--balance-positive {
  border-color: #c8f3dc;
  background: #e8f8e8;
}

.metric-panel--balance-positive .hero-number {
  color: #148848;
}

.metric-panel--balance-negative {
  border-color: #f8c7c7;
  background: #fde8e8;
}

.metric-panel--balance-negative .hero-number {
  color: #b42318;
}

.hero-number {
  display: block;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.mini-stat-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.mini-stat-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.mini-stat-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.mini-stat-list dd {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.book-panel {
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.settings-name-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.settings-name-form label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.settings-name-form button {
  min-width: 80px;
}

.compact-metrics {
  margin: 12px 0;
}

.compact-metrics .metric-card strong {
  font-size: 20px;
}

.merchant-card-list {
  display: grid;
  gap: 12px;
}

.merchant-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 15px;
}

.merchant-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.merchant-card__header h2 {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
}

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

.merchant-card__stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.merchant-card__stats div {
  min-width: 0;
  border-radius: 8px;
  background: #f7f7f7;
  padding: 9px 10px;
}

.merchant-card__stats dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.merchant-card__stats dd {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.merchant-card__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

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

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

.book-filter-actions {
  display: flex;
  justify-content: flex-end;
}

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

.book-summary-grid article {
  min-width: 0;
  border-radius: 8px;
  background: #f7f7f7;
  padding: 10px 8px;
  text-align: center;
}

.book-summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.book-summary-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.book-pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.book-pagination span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.book-pagination .btn:first-child {
  justify-self: start;
}

.book-pagination .btn:last-child {
  justify-self: end;
}

.ledger-card-list {
  display: grid;
  gap: 9px;
}

.ledger-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 14px;
  color: var(--text);
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.ledger-card:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: none;
}

.ledger-card--static:active {
  transform: none;
  box-shadow: var(--shadow);
}

.ledger-card__left,
.ledger-card__right {
  display: grid;
  gap: 6px;
  align-content: space-between;
}

.ledger-card__right {
  justify-items: end;
  text-align: right;
}

.ledger-card__title {
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.ledger-card__time,
.ledger-card__proof {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.ledger-card__amount {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.ledger-card__amount--positive {
  color: var(--success);
}

.ledger-card__amount--negative {
  color: var(--danger);
}

.ledger-card__proof-thumb {
  width: 52px;
  min-height: 52px;
  padding: 3px;
}

.ledger-card__proof-thumb img {
  width: 44px;
  height: 44px;
}

.payment-qr-preview {
  min-height: 76px;
  display: flex;
  align-items: center;
}

.payment-qr-preview__thumb {
  max-width: 180px;
}

.payment-qr-preview__thumb img {
  height: 150px;
}

.metric-grid,
.review-images,
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.metric-card,
.review-image,
.list-card,
.ledger-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 15px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.metric-card--link {
  display: block;
  color: var(--text);
  text-decoration: none;
}

.metric-card--link:hover,
.metric-card--link:focus-visible {
  border-color: rgba(7, 193, 96, 0.32);
  box-shadow: 0 2px 10px rgba(7, 193, 96, 0.12);
}

.detail-list {
  display: grid;
  grid-template-columns: minmax(96px, max-content) 1fr;
  gap: 10px 14px;
  margin: 0;
}

.detail-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.detail-list dd {
  margin: 0;
}

.credential-status-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.credential-status-item {
  min-width: 0;
  border-radius: 8px;
  background: #f7f7f7;
  padding: 10px 6px;
  text-align: center;
}

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

.credential-status-item span {
  color: var(--muted);
  font-size: 13px;
}

.credential-status-item strong {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 700;
}

.credential-status-item__ok {
  color: var(--success);
}

.credential-status-item__pending {
  color: #c47f00;
}

.credential-status-item__empty {
  color: var(--danger);
}

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

.inline-form {
  display: inline-grid;
}

.stack-form {
  max-width: 720px;
}

.image-thumb {
  width: 100%;
  max-width: 300px;
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  cursor: zoom-in;
  box-shadow: none;
}

.image-thumb img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: contain;
  border-radius: 10px;
  background: #f2f4f7;
}

.image-thumb span {
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

.proof-thumb {
  width: 70px;
  min-height: 70px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: none;
  cursor: zoom-in;
}

.proof-thumb img {
  display: block;
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  background: #f2f4f7;
}

.proof-thumb--expired,
.proof-thumb--expired:hover {
  border-style: dashed;
  background: #f7f7f7;
  color: var(--muted);
  cursor: default;
}

.expired-proof-placeholder {
  display: grid;
  place-items: center;
  min-height: 44px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}

.expired-proof-placeholder small {
  font-size: 11px;
}

.image-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.82);
}

.image-overlay__image {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 10px;
  background: #ffffff;
}

.image-overlay__message {
  max-width: 82vw;
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  padding: 18px;
  font-size: 15px;
  text-align: center;
}

.image-overlay__close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #ffffff;
  color: #111827;
  font-size: 22px;
  box-shadow: var(--shadow);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f0fff6;
  color: #148848;
  font-size: 13px;
  font-weight: 500;
}

.status--danger {
  background: #fee2e2;
  color: #991b1b;
}

.status--success {
  background: #dcfce7;
  color: #166534;
}

@media (max-width: 720px) {
  body {
    min-width: 0;
  }

  main {
    width: 100vw;
    max-width: 100%;
    padding: 60px 16px 64px;
  }

  .card,
  .metric-card,
  .review-image,
  .list-card,
  .ledger-group {
    padding: 15px;
  }

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

  .top-bar__inner {
    width: 100%;
    min-height: 48px;
    align-items: center;
    flex-direction: row;
  }

  .top-bar__account {
    position: absolute;
    right: 16px;
    width: auto;
    justify-content: flex-end;
    margin-left: 0;
  }

  .top-bar .logout-button {
    width: auto;
    min-height: 36px;
    padding-inline: 10px;
    font-size: 13px;
  }

  .bottom-bar__inner {
    width: 100%;
    padding-inline: 6px;
  }

  .btn,
  button,
  .admin-nav a,
  .merchant-nav a,
  .button-link {
    width: 100%;
  }

  .bottom-bar__inner .btn,
  .bottom-bar__inner a {
    width: auto;
    white-space: nowrap;
  }

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

  .merchant-card__header {
    align-items: flex-start;
  }

  .merchant-card__stats,
  .book-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .merchant-card__actions {
    justify-content: flex-end;
  }

  .merchant-card__actions .btn,
  .merchant-card__actions button,
  .merchant-card__actions .inline-form {
    width: auto;
  }

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

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

  .book-panel {
    max-height: calc(100vh - 160px);
  }

  .filter-form button {
    width: 100%;
  }

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

@media (max-width: 380px) {
  .book-summary-grid strong {
    font-size: 17px;
  }

  .book-pagination {
    gap: 6px;
  }

  .book-pagination .btn {
    padding-inline: 12px;
  }
}
