@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Noto+Sans+SC:wght@400;500;700&display=swap');

:root {
  --bg: #f3f6fb;
  --bg-soft: #eef3fa;
  --ink: #17233a;
  --ink-2: #243652;
  --muted: #6b7d97;

  --surface: #ffffff;
  --surface-2: #f8fbff;
  --line: #dce5f1;
  --line-strong: #cbd8eb;

  --nav-bg: #121c2f;
  --nav-bg-2: #0f1727;
  --nav-ink: #d9e5f9;
  --nav-muted: #9fb3d9;

  --brand: #0d57d6;
  --brand-2: #2f7bff;
  --ok: #15825f;
  --danger: #c0394d;

  --radius: 14px;
  --shadow-sm: 0 6px 16px rgba(16, 35, 69, 0.08);
  --shadow: 0 18px 42px rgba(16, 35, 69, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: "Plus Jakarta Sans", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(860px 420px at 110% -10%, rgba(20, 86, 190, 0.14), transparent 60%),
    radial-gradient(780px 380px at -10% 110%, rgba(45, 110, 212, 0.1), transparent 60%),
    linear-gradient(180deg, #f7f9fd, var(--bg));
}

.bg-auth,
.bg-app {
  background:
    radial-gradient(860px 420px at 110% -10%, rgba(20, 86, 190, 0.14), transparent 60%),
    radial-gradient(780px 380px at -10% 110%, rgba(45, 110, 212, 0.1), transparent 60%),
    linear-gradient(180deg, #f7f9fd, var(--bg));
}

h1, h2 {
  margin: 0 0 10px;
  line-height: 1.18;
  color: var(--ink-2);
}

h1 {
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 800;
}

h2 {
  font-size: clamp(19px, 2vw, 26px);
  font-weight: 700;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
}

.topbar-strong {
  background: rgba(247, 250, 255, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.wrap {
  max-width: 1360px;
  margin: 16px auto;
  padding: 0 16px 28px;
  display: grid;
  gap: 16px;
}

.wrap-wide { max-width: 1420px; }

.card {
  background: linear-gradient(180deg, #fff, #fcfdff);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.panel-gradient {
  background:
    linear-gradient(105deg, rgba(13, 87, 214, 0.09), rgba(47, 123, 255, 0.06)),
    var(--surface);
  border-color: var(--line-strong);
}

.auth-shell {
  min-height: 100vh;
  padding: 22px;
}

.auth-shell-split {
  display: grid;
  grid-template-columns: 1.1fr minmax(360px, 460px);
  gap: 22px;
  align-items: center;
  max-width: 1180px;
  margin: 0 auto;
}

.auth-hero {
  padding: 20px;
}

.auth-hero h1 span {
  display: block;
  margin-top: 6px;
  font-size: clamp(20px, 2.2vw, 32px);
  color: #244577;
  font-weight: 600;
}

.hero-badges,
.chip-row {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-badges span,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: #2d4468;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.auth-card-elevated { justify-self: end; }

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

label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: #2c4165;
}

input, select, button { font: inherit; }

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
select:focus {
  border-color: rgba(13, 87, 214, 0.45);
  box-shadow: 0 0 0 4px rgba(13, 87, 214, 0.12);
}

.btn {
  border: 1px solid transparent;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
  box-shadow: 0 10px 20px rgba(20, 74, 170, 0.2);
}

.btn.ghost {
  background: #fff;
  border-color: var(--line);
  color: #2d456f;
  box-shadow: none;
}

.btn.danger {
  background: linear-gradient(135deg, #bf2d41, #dc4055);
}

.btn.danger:hover {
  box-shadow: 0 10px 20px rgba(170, 20, 47, 0.25);
}

.switch-link {
  margin-top: 12px;
  text-align: right;
}

.switch-link a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 700;
}

.captcha-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.captcha-box {
  min-height: 52px;
  border: 1px dashed var(--line-strong);
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: #fff;
}

.admin-shell {
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: start;
}

.admin-sidebar {
  position: sticky;
  top: 80px;
  background: linear-gradient(180deg, var(--nav-bg), var(--nav-bg-2));
  border-color: rgba(172, 193, 229, 0.18);
  color: var(--nav-ink);
  box-shadow: 0 18px 42px rgba(8, 19, 37, 0.35);
}

.admin-sidebar h2 { color: #eff5ff; }

.admin-nav {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.admin-nav a {
  display: block;
  border: 1px solid rgba(162, 185, 220, 0.2);
  border-radius: 10px;
  background: rgba(172, 196, 233, 0.08);
  color: var(--nav-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 12px;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.admin-nav a:hover {
  color: #ecf4ff;
  background: rgba(161, 185, 225, 0.16);
}

.admin-nav a.active {
  color: #fff;
  border-color: rgba(174, 205, 255, 0.42);
  background: linear-gradient(120deg, rgba(56, 116, 219, 0.6), rgba(67, 142, 255, 0.46));
}

.admin-main {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.inline-actions {
  margin: 14px 0 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.inline-actions form { margin: 0; }

.query-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.query-grid-compact { margin-top: 14px; }
.query-grid-client {
  grid-template-columns: minmax(0, 1fr) minmax(130px, 180px) auto;
  margin: 0;
  align-items: end;
}

.pagination-bar {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.batch-form { gap: 14px; }

.batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.fund-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}

.btn.btn-xs {
  padding: 5px 8px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.account-picker {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
  padding: 10px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: 340px;
  overflow: auto;
}

.check-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.check-card input { width: auto; }
.check-title { font-size: 14px; font-weight: 700; }
.check-sub { font-size: 12px; color: var(--muted); }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  max-width: 100%;
}

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

th,
td {
  text-align: left;
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid #e8eef8;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f6fd;
  color: #334a70;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:hover td { background: #f8fbff; }

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #cfe0fb;
  background: #edf4ff;
  color: #2b4a7a;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
}

.status-chip.status-ok {
  border-color: #bfe8d8;
  background: #e9f9f2;
  color: #157a59;
}

.status-chip.status-failed {
  border-color: #f1c4cc;
  background: #fff0f3;
  color: #b02d3f;
}

.fund-log-table {
  table-layout: fixed;
  min-width: 1320px;
}

.fund-log-table th,
.fund-log-table td {
  vertical-align: top;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-text {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fund-log-wrap {
  overflow-x: auto;
  overflow-y: hidden;
}

.fund-log-table .col-time { width: 130px; }
.fund-log-table .col-operator { width: 160px; }
.fund-log-table .col-op-type { width: 130px; }
.fund-log-table .col-bc { width: 170px; }
.fund-log-table .col-account { width: 150px; }
.fund-log-table .col-amount { width: 110px; }
.fund-log-table .col-status { width: 110px; }
.fund-log-table .col-error { width: 190px; }
.fund-log-table .col-detail { width: 80px; }

.log-detail-json {
  margin: 0;
  max-height: 360px;
  overflow: auto;
  white-space: pre;
  background: #f6f9ff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.45;
}

.alert {
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid transparent;
}

.alert.error {
  background: #fff1f3;
  border-color: #ffd5dc;
  color: var(--danger);
}

.alert.ok {
  background: #ebfaf3;
  border-color: #c8eedf;
  color: var(--ok);
}

.list {
  margin: 0;
  padding-left: 18px;
}

.list li { margin: 6px 0; }

.span-all { grid-column: 1 / -1; }

.security-card {
  border-radius: 16px;
}

.security-actions .btn,
.security-actions form .btn {
  min-width: 190px;
}

.otp-setup-grid {
  margin: 12px 0 14px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.otp-qr-wrap {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(15, 47, 96, 0.08);
}

.otp-qr-img {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1 / 1;
  display: block;
  border-radius: 10px;
}

.otp-meta { min-width: 0; }

.kv-grid {
  display: grid;
  gap: 10px;
}

.kv-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fbff;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
}

.kv-item span {
  font-size: 12px;
  color: var(--muted);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.4;
  color: #20385f;
}

.break-all {
  word-break: break-all;
  white-space: normal;
}

.client-list {
  display: grid;
  gap: 8px;
}

.client-line {
  display: grid;
  grid-template-columns: 1.1fr 1fr 0.9fr 0.9fr 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
  padding: 10px 12px;
  font-size: 13px;
}

.client-name {
  color: #1f3861;
  font-weight: 700;
}

.client-meta {
  color: #486185;
}

.client-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  place-items: center;
  padding: 14px;
  background: rgba(10, 21, 40, 0.5);
}

.modal-overlay.is-open { display: grid; }

.modal-panel {
  width: min(540px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 16px;
  box-shadow: var(--shadow);
}

.modal-panel-wide {
  width: min(1020px, calc(100vw - 28px));
}

#bind-bc-modal .modal-panel {
  width: min(900px, calc(100vw - 28px));
}

#assign-assets-modal .modal-panel {
  width: min(900px, calc(100vw - 28px));
}

#bind-bc-modal table {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
}

#assign-assets-modal table {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
}

#bind-bc-modal th,
#bind-bc-modal td {
  font-size: 12px;
}

#assign-assets-modal th,
#assign-assets-modal td {
  font-size: 12px;
}

#bind-bc-modal .bind-result-table th:nth-child(1),
#bind-bc-modal .bind-result-table td:nth-child(1) {
  width: 32%;
}

#bind-bc-modal .bind-result-table th:nth-child(2),
#bind-bc-modal .bind-result-table td:nth-child(2) {
  width: 30%;
}

#bind-bc-modal .bind-result-table th:nth-child(3),
#bind-bc-modal .bind-result-table td:nth-child(3) {
  width: 38%;
}

#assign-assets-modal .bind-result-table th:nth-child(1),
#assign-assets-modal .bind-result-table td:nth-child(1) {
  width: 28%;
}

#assign-assets-modal .bind-result-table th:nth-child(2),
#assign-assets-modal .bind-result-table td:nth-child(2) {
  width: 30%;
}

#assign-assets-modal .bind-result-table th:nth-child(3),
#assign-assets-modal .bind-result-table td:nth-child(3) {
  width: 42%;
}

#bind-bc-modal td.result-cell {
  white-space: normal;
  word-break: break-word;
}

.modal-close-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 6px;
}

.modal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

@media (max-width: 1120px) {
  .auth-shell-split,
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .auth-card-elevated {
    justify-self: stretch;
  }

  .admin-sidebar {
    position: static;
  }

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

@media (max-width: 760px) {
  .topbar {
    padding: 12px 14px;
    gap: 8px;
    align-items: flex-start;
  }

  .auth-shell { padding: 12px; }
  .wrap { padding: 0 10px 20px; }

  .card {
    padding: 14px;
    border-radius: 12px;
  }

  .query-grid,
  .account-picker,
  .client-line {
    grid-template-columns: 1fr;
  }

  .otp-setup-grid {
    grid-template-columns: 1fr;
  }

  .security-actions .btn,
  .security-actions form .btn {
    min-width: 0;
    width: 100%;
  }
}
