:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #dce1e7;
  --text: #1f2933;
  --muted: #64748b;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #b42318;
  --warning: #a16207;
  --success: #137333;
  --shadow: 0 12px 28px rgba(24, 39, 75, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

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

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

code,
pre {
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 68px;
  padding: 10px clamp(16px, 4vw, 40px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--text);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
}

.nav a {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.nav a.active,
.nav a:hover {
  background: #e8f3f1;
  color: var(--primary-dark);
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 28px auto 56px;
}

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

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

h1 {
  font-size: clamp(1.65rem, 2.4vw, 2.25rem);
  margin-bottom: 6px;
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 14px;
}

p {
  color: var(--muted);
}

.panel,
.auth-panel,
.checkout-summary,
.payment-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats-grid article {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats-grid span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.stats-grid strong {
  font-size: 1.7rem;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

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

th {
  color: var(--muted);
  font-weight: 700;
  background: #fafafa;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: #475569;
  font-size: .85rem;
  font-weight: 700;
}

.badge.paid,
.badge.sent {
  background: #e7f6ec;
  color: var(--success);
}

.badge.pending,
.badge.manual_review {
  background: #fff7df;
  color: var(--warning);
}

.badge.failed,
.badge.cancelled {
  background: #fdecec;
  color: var(--danger);
}

.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

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

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.danger {
  border-color: #f1b5b0;
  color: var(--danger);
}

.btn.small {
  min-height: 34px;
  padding: 6px 10px;
}

.icon-btn {
  width: 40px;
  padding: 0;
}

.actions,
.action-row,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

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

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

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

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.check input {
  width: auto;
}

.details {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px 14px;
  margin: 0;
}

.details dt {
  color: var(--muted);
  font-weight: 700;
}

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

pre {
  padding: 12px;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  max-height: 280px;
  overflow: auto;
}

.flash {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #eef8f6;
  color: var(--primary-dark);
  font-weight: 700;
}

.flash.error {
  background: #fdecec;
  color: var(--danger);
}

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

.auth-panel {
  width: min(430px, 100%);
  padding: 28px;
}

.login-brand {
  margin-bottom: 20px;
}

.checkout-shell {
  width: min(980px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 18px;
}

.checkout-summary,
.payment-panel {
  padding: 26px;
}

.payment-methods {
  display: grid;
  gap: 12px;
}

.cancel-payment-form {
  margin-top: 12px;
}

.method {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.method input {
  width: auto;
}

.method small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.gateway-list {
  display: grid;
  gap: 18px;
}

@media (max-width: 920px) {
  .topbar,
  .page-head {
    flex-wrap: wrap;
  }

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

  .split-grid,
  .details-grid,
  .checkout-shell,
  .grid-form {
    grid-template-columns: 1fr;
  }

  .checkout-shell {
    align-content: center;
    padding: 24px 0;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1280px);
    margin-top: 18px;
  }

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

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

  .topbar {
    padding-inline: 10px;
  }
}
