:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --ink: #101828;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --brand: #8a1f24;
  --brand-2: #621217;
  --brand-soft: #fff1f2;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --ok: #039855;
  --ok-soft: #ecfdf3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-soft: 0 1px 2px rgba(16, 24, 40, .04), 0 12px 30px rgba(16, 24, 40, .05);
  --radius: 8px;
  --sidebar-w: 244px;
  --content-max: 1680px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard", "Inter", "Malgun Gothic", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  min-height: 100vh;
  display: flex;
}
.sidebar {
  position: sticky;
  top: 0;
  width: var(--sidebar-w);
  height: 100vh;
  overflow-y: auto;
  flex: 0 0 auto;
  background: #ffffff;
  color: var(--ink);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
}
.brand-logo {
  display: flex;
  align-items: center;
  height: 58px;
  padding: 0 4px;
  overflow: hidden;
}
.brand-logo img {
  display: block;
  width: 100%;
  /* height: 54px; */
  max-width: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 4px;
}
.login-logo img {
  display: block;
  width: 320px;
  /* height: 112px; */
  max-width: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 6px;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border: 7px solid #111827;
  border-radius: 50%;
  display: inline-block;
  position: relative;
  flex: 0 0 auto;
}
.brand-mark:after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: var(--brand);
  border: 3px solid #fff;
  border-radius: 50%;
}
.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -4px 0 22px;
}
.mode {
  display: inline-flex;
  align-items: center;
  height: 24px;
  margin: 10px 8px 16px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-2);
  font-size: 11px;
  font-weight: 800;
}
.nav {
  display: grid;
  gap: 3px;
}
.nav a {
  display: flex;
  align-items: center;
  min-height: 38px;
  color: #344054;
  padding: 9px 10px;
  border-radius: 8px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.nav a:hover {
  background: #fff7f7;
  color: var(--brand-2);
  text-decoration: none;
}
.nav a.active {
  background: var(--brand-soft);
  color: var(--brand-2);
  box-shadow: inset 3px 0 0 var(--brand);
  text-decoration: none;
}
.sidebar-balance {
  margin: 18px 4px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 800;
}
.sidebar-balance-master {
  display: grid;
  gap: 10px;
}
.sidebar-balance-row {
  display: grid;
  gap: 3px;
}
.sidebar-balance-row span,
.sidebar-balance-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.sidebar-balance-label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}
.sidebar-balance-row strong,
.sidebar-balance-master strong {
  display: block;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.2;
  font-weight: 900;
}

.main {
  min-width: 0;
  flex: 1;
  width: calc(100vw - var(--sidebar-w));
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 28px 32px 48px;
}
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
h1, h2, h3 { letter-spacing: 0; }
h1 { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 850; }
h2 { margin: 0 0 14px; font-size: 17px; line-height: 1.3; font-weight: 850; }
h3 { margin: 0 0 10px; font-size: 14px; font-weight: 850; }
.subtle { color: var(--muted); margin-top: 5px; font-size: 13px; }

.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
}
.metric {
  min-height: 104px;
}
.metric .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.metric .value {
  margin-top: 8px;
  color: var(--ink);
  font-size: 26px;
  line-height: 1.15;
  font-weight: 900;
  overflow-wrap: anywhere;
}
.metric .value.small {
  font-size: 20px;
  line-height: 1.25;
}
.metric .value.metric-period {
  font-size: 18px;
  line-height: 1.35;
}
.metric .metric-note {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.funds-balance-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 76px;
  margin: 2px 0 14px;
  padding: 14px 16px;
  border: 1px solid #dbeafe;
  border-radius: var(--radius);
  background: #f8fbff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.funds-balance-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.funds-balance-panel strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.15;
  font-weight: 900;
  overflow-wrap: anywhere;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.stat {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--panel-soft);
}
.stat span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; margin-bottom: 7px; }
.stat strong { display: block; font-size: 17px; overflow-wrap: anywhere; }

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.toolbar h2 { margin-right: auto; margin-bottom: 0; }
.idle-logout-timer {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}
.idle-logout-timer.is-warning {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-2); border-color: var(--brand-2); color: #fff; text-decoration: none; }
.btn.secondary { background: #fff; color: #344054; border-color: var(--line-strong); }
.btn.disabled,
.btn[aria-disabled="true"] {
  pointer-events: none;
  opacity: .45;
}
.btn.secondary:hover { background: #fff7f7; color: var(--brand-2); border-color: #d9a1a5; }
.btn.danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.btn.danger:hover { border-color: #b42318; background: #b42318; color: #fff; }
.btn.small { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.inline-form {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 4px 2px 0;
}
.inline-form input { width: 150px; min-height: 30px; padding: 6px 8px; font-size: 12px; }
.inline-form select { width: auto; min-width: 104px; min-height: 30px; padding: 6px 8px; font-size: 12px; }
form label {
  display: block;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
  margin: 12px 0 6px;
}
input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
  font: inherit;
  background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { min-height: 180px; font-family: Consolas, "D2Coding", monospace; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { margin-top: 16px; }
.fund-adjust-grid {
  grid-template-columns: minmax(140px, 1fr) minmax(260px, 1.6fr) minmax(160px, 1fr) minmax(240px, 1.4fr);
  align-items: start;
}
.fund-adjust-grid .form-actions { margin-top: 34px; }
.search-panel { padding-top: 14px; }

.alert {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 12px 0;
  font-weight: 700;
}
.alert.error,
.alert.danger {
  position: sticky;
  top: 10px;
  z-index: 30;
  background: #fff1f0;
  color: #b42318;
  border: 1px solid #fda29b;
  box-shadow: 0 10px 24px rgba(180, 35, 24, .12);
}
.alert.ok,
.alert.success { background: var(--ok-soft); color: var(--ok); border: 1px solid #abefc6; }
.alert.warning { background: var(--warn-soft); color: var(--warn); border: 1px solid #fedf89; }
.compact-alert { margin-bottom: 0; }
.admin-toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}
.admin-toast {
  pointer-events: auto;
  border-radius: 8px;
  padding: 13px 15px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(16, 24, 40, .18);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.45;
  animation: toast-in .18s ease-out;
}
.admin-toast-error { background: #fff1f0; color: #b42318; border-color: #fda29b; }
.admin-toast-success { background: var(--ok-soft); color: #027a48; border-color: #abefc6; }
.admin-toast-warning { background: var(--warn-soft); color: #b54708; border-color: #fedf89; }
.admin-toast.is-hiding {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.inline-action {
  display: flex;
  gap: 8px;
  align-items: center;
}
.inline-action input,
.inline-action select {
  flex: 1;
  min-width: 0;
}
.inline-action .btn {
  white-space: nowrap;
}

.badge, .status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}
.badge.success, .status.success { background: var(--ok-soft); color: #027a48; }
.badge.warning, .status.warning, .status.processing, .status.requested { background: var(--warn-soft); color: var(--warn); }
.badge.danger, .status.failed { background: var(--danger-soft); color: #b42318; }
.status.rejected, .status.cancelled { background: #f2f4f7; color: #475467; }
.badge-list { display: flex; flex-wrap: wrap; gap: 5px; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  table-layout: auto;
}
.table-scroll {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}
th, td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}
th {
  background: #f9fafb;
  color: #475467;
  font-size: 12px;
  font-weight: 850;
}
tfoot th, tfoot td {
  background: #f9fafb;
  color: var(--ink);
  font-weight: 850;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}
tbody tr:hover td { background: #fcfcfd; }
tbody tr:last-child td { border-bottom: 0; }

pre {
  margin: 0;
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  white-space: pre-wrap;
  max-height: 360px;
  overflow: auto;
  font-size: 12px;
}
.log-json { max-height: 260px; margin-bottom: 14px; }
.log-error { max-width: 220px; color: var(--danger); overflow-wrap: anywhere; }
.text-danger { color: var(--danger) !important; }
.log-table td { vertical-align: top; }
.audit-log-scroll { border: 1px solid var(--line); border-radius: var(--radius); }
.audit-log-table { min-width: 1180px; border: 0; border-radius: 0; }
.audit-log-table th:nth-child(1), .audit-log-table td:nth-child(1) { width: 64px; white-space: nowrap; }
.audit-log-table th:nth-child(2), .audit-log-table td:nth-child(2) { width: 130px; }
.audit-log-table th:nth-child(3), .audit-log-table td:nth-child(3) { width: 210px; }
.audit-log-table th:nth-child(4), .audit-log-table td:nth-child(4) { width: 150px; }
.audit-log-table th:nth-child(6), .audit-log-table td:nth-child(6) { width: 220px; }
.audit-log-table th:nth-child(7), .audit-log-table td:nth-child(7) { width: 150px; white-space: nowrap; }
.audit-log-table .change-table { table-layout: fixed; min-width: 420px; }
.audit-log-table .meta-list {
  display: grid;
  grid-template-columns: minmax(90px, max-content) minmax(160px, 1fr);
  gap: 5px 10px;
  min-width: 320px;
}
.audit-log-table .meta-list dt,
.audit-log-table .meta-list dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, #ffffff 0, #f6f8fb 45%, #eef2f7 100%);
}
.login-box {
  width: min(390px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.login-box h1 { margin-bottom: 6px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .48);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(520px, 100%);
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: 0 22px 60px rgba(16, 24, 40, .24);
}
.modal-wide { width: min(720px, 100%); }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; }
.modal-body { padding: 18px 20px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #fcfcfd;
}
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.icon-btn:hover { background: var(--panel-soft); color: var(--ink); }
.check-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.check-row input { width: auto; min-height: 0; }
.permission-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 4px 14px;
}
.permission-grid > label:first-child {
  grid-column: 1 / -1;
}

.meta-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 5px 10px;
  margin: 0;
  min-width: 220px;
}
.meta-list dt { color: var(--muted); font-size: 12px; font-weight: 850; }
.meta-list dd { margin: 0; overflow-wrap: anywhere; }
.change-table {
  width: 100%;
  min-width: 300px;
  border: 1px solid var(--line);
  margin-bottom: 8px;
  border-collapse: collapse;
}
.change-table th, .change-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); font-size: 12px; text-align: left; }
.change-table th { color: var(--muted); font-weight: 850; }
.change-table tr.changed td { background: var(--warn-soft); }
.user-agent { max-width: 220px; overflow-wrap: anywhere; }
.raw-log summary { cursor: pointer; color: var(--brand-2); font-weight: 850; }
.raw-log-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(240px, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.data-table,
.log-table,
.audit-log-table {
  font-size: 13px;
}

.data-table th,
.data-table td,
.log-table th,
.log-table td {
  padding: 10px 12px;
}

.section-head { margin-bottom: 4px; }
.page-section-title { margin: 10px 0 12px; }
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.pagination-summary {
  color: var(--muted);
  font-size: 13px;
}
.pagination-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.pagination-gap {
  color: var(--muted);
  font-size: 13px;
  padding: 0 2px;
}

.merchant-list {
  display: grid;
  gap: 12px;
}
.merchant-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.merchant-summary {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(300px, 520px) minmax(170px, 260px);
  gap: 16px;
  align-items: start;
  padding: 16px;
}

.mobile-nav-toggle,
.mobile-nav-backdrop {
  display: none;
}
.merchant-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.merchant-title-row h3 {
  margin: 0;
  font-size: 16px;
}
.merchant-id {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.merchant-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}
.merchant-money {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}
.merchant-money div {
  min-height: 66px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}
.merchant-money span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  margin-bottom: 6px;
}
.merchant-money strong {
  display: block;
  font-size: 16px;
  overflow-wrap: anywhere;
}
.merchant-quick-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.merchant-quick-actions .btn {
  min-width: 78px;
}
.merchant-control-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
}
.merchant-control {
  min-width: 0;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.merchant-control:nth-child(1) { grid-column: span 5; }
.merchant-control:nth-child(2) { grid-column: span 3; }
.merchant-control:nth-child(3) { grid-column: span 4; border-right: 0; }
.merchant-control:nth-child(4) { grid-column: span 3; border-bottom: 0; }
.merchant-control:nth-child(5) { grid-column: span 6; border-bottom: 0; }
.merchant-control:nth-child(6) { grid-column: span 3; border-right: 0; border-bottom: 0; }
.merchant-control-wide { min-width: 0; }
.merchant-control h3 {
  color: #344054;
  font-size: 13px;
  margin-bottom: 10px;
}
.merchant-control p { margin: 0; color: var(--muted); }
.compact-form, .api-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}
.compact-form select { min-width: 136px; flex: 1 1 180px; }
.compact-form select, .compact-form input, .api-form input {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}
.api-form input { min-width: 150px; flex: 1 1 220px; }
.policy-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 10px;
}
.policy-summary div {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}
.policy-summary dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}
.policy-summary dd {
  margin: 3px 0 0;
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.limit-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 7px;
  align-items: end;
}
.limit-form .btn {
  min-width: max-content;
}

@media (min-width: 1600px) {
  .main {
    padding-left: 36px;
    padding-right: 36px;
  }
  .card {
    padding: 18px;
  }
  .form-grid {
    gap: 2px 18px;
  }
  .metric .value {
    font-size: 28px;
  }
  .metric .value.small {
    font-size: 20px;
  }
  .metric .value.metric-period {
    font-size: 18px;
  }
}
.limit-form label {
  margin: 0;
}
.limit-form label span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  margin-bottom: 4px;
}
.limit-form input {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}
.api-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}
.api-key-issued {
  display: block;
}
.api-key-copy {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.api-key-copy code {
  display: block;
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #fedf89;
  border-radius: var(--radius);
  background: #fff;
  color: #101828;
  font-family: Consolas, "D2Coding", monospace;
  overflow-wrap: anywhere;
}
.control-actions {
  margin-top: 10px;
}
.empty-state {
  padding: 22px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
  font-weight: 800;
}

.tour-overlay[hidden] { display: none; }
.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}
.tour-dim {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .38);
}
.tour-popover {
  position: fixed;
  width: 360px;
  min-height: 220px;
  border: 1px solid #facc15;
  border-radius: var(--radius);
  background: #fffef4;
  box-shadow: 0 24px 70px rgba(16, 24, 40, .26);
  padding: 18px;
  pointer-events: auto;
}
.tour-popover h2 {
  margin: 6px 0 8px;
  color: #111827;
  font-size: 20px;
}
.tour-popover p {
  margin: 0 0 12px;
  color: #475467;
  font-size: 14px;
  line-height: 1.55;
}
.tour-step {
  color: #a16207;
  font-size: 12px;
  font-weight: 900;
}
.tour-check {
  color: #344054;
  font-size: 13px;
  font-weight: 750;
}
.tour-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 12px;
}
.tour-arrow {
  position: fixed;
  width: 24px;
  height: 24px;
  background: #facc15;
  transform: rotate(45deg);
  z-index: 101;
}
.tour-arrow.left {
  background: #facc15;
}
.tour-target-active {
  position: relative;
  z-index: 102;
  outline: 3px solid #facc15;
  outline-offset: 4px;
  box-shadow: 0 0 0 8px rgba(250, 204, 21, .24);
}

.divider {
  height: 1px;
  margin: 16px 0;
  background: var(--line);
}
.soft-card {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}
.soft-card h3,
.soft-card h4 {
  margin-top: 0;
}

@media (max-width: 1100px) {
  .grid.cols-4, .grid.cols-3, .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { width: calc(100vw - var(--sidebar-w)); padding: 24px 22px 42px; }
  .merchant-summary { grid-template-columns: 1fr; }
  .merchant-quick-actions { justify-content: flex-start; }
  .merchant-control:nth-child(1),
  .merchant-control:nth-child(3),
  .merchant-control:nth-child(5) { grid-column: span 12; border-right: 0; border-bottom: 1px solid var(--line); }
  .merchant-control:nth-child(2),
  .merchant-control:nth-child(4),
  .merchant-control:nth-child(6) { grid-column: span 4; border-bottom: 0; }
  .merchant-control:nth-child(6) { border-right: 0; }
}
@media (max-width: 900px) {
  body.mobile-nav-locked { overflow: hidden; }
  .shell { display: block; min-height: 100vh; }
  .mobile-nav-toggle {
    position: fixed;
    left: 12px;
    top: 12px;
    z-index: 80;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 8px 12px;
    font-weight: 900;
    box-shadow: var(--shadow);
  }
  .mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 65;
    display: block;
    background: rgba(15, 23, 42, .42);
  }
  .mobile-nav-backdrop[hidden] { display: none; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70;
    width: min(82vw, 320px);
    height: 100vh;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: 18px 0 48px rgba(16, 24, 40, .18);
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  .shell.nav-open .sidebar { transform: translateX(0); }
  .nav { grid-template-columns: 1fr; }
  .main {
    width: 100%;
    max-width: none;
    padding: 72px 14px 34px;
  }
  .topbar { display: block; }
  .topbar .toolbar { margin-top: 12px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2, .form-grid, .stats-grid, .raw-log-grid { grid-template-columns: 1fr; }
  .merchant-money, .policy-summary, .limit-form { grid-template-columns: 1fr; }
  .merchant-control-grid { grid-template-columns: 1fr; }
  .merchant-control,
  .merchant-control:nth-child(1),
  .merchant-control:nth-child(2),
  .merchant-control:nth-child(3),
  .merchant-control:nth-child(4),
  .merchant-control:nth-child(5),
  .merchant-control:nth-child(6) {
    grid-column: 1 / -1;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .merchant-control:last-child { border-bottom: 0; }
  .compact-form, .api-form { align-items: stretch; flex-direction: column; }
  .compact-form select, .compact-form input, .api-form input { width: 100%; }
  .api-key-copy { align-items: stretch; flex-direction: column; }
  .api-key-copy .btn { width: 100%; }
  .tour-popover { width: calc(100vw - 32px) !important; left: 16px !important; top: auto !important; bottom: 16px; }
  .tour-arrow { display: none; }
  table { min-width: 760px; }
  .card { padding: 14px; }
  th, td { min-width: 110px; }
  .modal-backdrop { align-items: end; padding: 10px; }
  .modal, .modal-wide {
    width: 100%;
    max-height: calc(100vh - 20px);
    overflow: auto;
  }
  .modal-actions { position: sticky; bottom: 0; }
}
@media (max-width: 560px) {
  body { font-size: 13px; }
  h1 { font-size: 21px; }
  h2 { font-size: 16px; }
  .metric .value { font-size: 22px; }
  .metric .value.small { font-size: 18px; }
  .metric .value.metric-period { font-size: 16px; }
  .toolbar { align-items: stretch; }
  .toolbar .btn { flex: 1 1 auto; }
  .stats-grid, .grid.cols-4, .grid.cols-3, .grid.cols-2 { gap: 10px; }
  .stat, .metric { min-height: 74px; }
  .form-actions .btn,
  .modal-actions .btn {
    flex: 1 1 auto;
  }
  input, select, textarea { min-height: 42px; }
}

.otp-enroll {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-top: 12px;
}
.otp-qr {
  display: grid;
  place-items: center;
  width: 196px;
  min-height: 196px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.otp-qr img,
.otp-qr canvas {
  display: block;
}
code {
  display: inline-block;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}
@media (max-width: 720px) {
  .otp-enroll {
    grid-template-columns: 1fr;
  }
}

.account-format-invalid {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}
.account-format-warning {
  margin-top: 6px;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}
