/* components.css : buttons, cards, forms, tables, status, tally, toast, modal */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: var(--radius-control);
  border: 1px solid transparent; background: var(--text); color: var(--bg);
  font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn:hover { background: #ffffff; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: var(--hairline-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; border-color: rgba(212, 112, 95, .4); color: var(--bad); }
.btn-danger:hover { background: rgba(212, 112, 95, .1); }
.btn-sm { height: 28px; padding: 0 12px; font-size: 13px; border-radius: 6px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn.is-loading::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; opacity: .7;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; background: transparent; border: 1px solid var(--hairline-strong); border-radius: var(--radius-control); color: var(--text-2); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.text-link { background: none; border: 0; padding: 0; color: var(--text-2); cursor: pointer; font-size: 13px; text-decoration: none; }
.text-link:hover { color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-card); padding: 24px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 20px; }
.stat-label { color: var(--text-2); font-size: 13px; }
.stat-value { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 24px; line-height: 32px; font-weight: 400; }
.stat-hero .stat-value { font-size: 32px; line-height: 40px; color: var(--accent); }
.stat-foot { margin-top: 8px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field label { font-size: 13px; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 12px; border-radius: var(--radius-control);
  background: var(--bg); border: 1px solid var(--hairline-strong); outline: none;
  transition: border-color var(--fast) var(--ease);
}
.textarea { height: auto; min-height: 96px; padding: 8px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--text-2); }
.hint { color: var(--muted); font-size: 13px; }
.checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.charge-box { border-top: 1px solid var(--hairline); padding: 16px 0; display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.charge-box span:last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 20px; }
.info-box { background: var(--bg); border: 1px solid var(--hairline); border-radius: var(--radius-control); padding: 12px; margin-bottom: 16px; color: var(--text-2); white-space: pre-wrap; }

.table-wrap { overflow-x: auto; border: 1px solid var(--hairline); border-radius: var(--radius-card); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.table th { background: var(--surface); color: var(--muted); font-weight: 400; white-space: nowrap; }
.table td.text-right, .table th.text-right { font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--fast) var(--ease); }
.table tbody tr:hover { background: rgba(236, 235, 231, .02); }
.table td.empty { text-align: center; color: var(--muted); padding: 32px; }
.table .group-row td { background: var(--bg); color: var(--text-2); padding-top: 16px; }
.link-cell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-cell a { color: var(--text-2); }

.toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 200px; flex: 1; max-width: 320px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { height: 28px; padding: 0 12px; border-radius: 6px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; font-size: 13px; text-transform: capitalize; transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease); }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-2); border-color: var(--hairline); color: var(--text); }

/* Status: a dot + quiet text, color only on the dot */
.badge { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); text-transform: capitalize; white-space: nowrap; --dot: var(--muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dot); }
.badge-processing, .badge-waiting, .badge-confirming, .badge-sending, .badge-created, .badge-refund { --dot: var(--info); }
.badge-completed, .badge-active, .badge-deposit, .badge-finished, .badge-confirmed { --dot: var(--good); }
.badge-partial, .badge-partially_paid, .badge-admin { --dot: var(--warn); }
.badge-canceled, .badge-hidden, .badge-banned, .badge-expired, .badge-failed, .badge-refunded { --dot: var(--bad); }

/* Signature: the tally (delivered / ordered + a 2px rule) */
.tally { display: inline-flex; flex-direction: column; gap: 6px; min-width: 112px; }
.tally-figure { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text); white-space: nowrap; }
.tally-figure span { color: var(--muted); }
.tally-rule { display: block; height: 2px; }
.tally-track { fill: var(--surface-3); }
.tally-fill { fill: var(--accent); }

.toast-wrap { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--hairline-strong); padding: 12px 16px; border-radius: var(--radius-control); max-width: 360px; animation: rise var(--slow) var(--ease); }
.toast::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.toast-error::before { background: var(--bad); }
.toast-info::before { background: var(--info); }
@keyframes rise { from { transform: translateY(4px); opacity: 0; } }

.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 90; }
.modal { background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: var(--radius-panel); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; padding: 24px; animation: rise var(--slow) var(--ease); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.loading-block { padding: 32px; text-align: center; color: var(--muted); }
