@import url("https://fonts.googleapis.com/css2?family=Karla:wght@400;600;700&family=Space+Grotesk:wght@400;600;700&display=swap");

:root {
  --bg: #f4f1ec;
  --bg-2: #f9f6f1;
  --ink: #1c1a16;
  --muted: #6f6358;
  --accent: #1f7a8c;
  --accent-2: #ef476f;
  --accent-3: #ffd166;
  --card: #fffdf9;
  --line: #e7ded4;
  --shadow: 0 18px 45px rgba(26, 20, 12, 0.12);
  --radius: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Karla", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 600px at 10% 0%, #ffffff 0%, #f4f1ec 50%, #f1ede7 100%),
    linear-gradient(135deg, #f8f3ec 0%, #f0ece7 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle at 20% 20%, rgba(31, 122, 140, 0.08) 0, transparent 45%),
    radial-gradient(circle at 80% 10%, rgba(239, 71, 111, 0.08) 0, transparent 40%),
    radial-gradient(circle at 70% 80%, rgba(255, 209, 102, 0.1) 0, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

h1,
h2,
h3 {
  font-family: "Space Grotesk", "Karla", sans-serif;
  margin: 0 0 10px;
}

button,
input,
select {
  font-family: inherit;
}

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

a:hover {
  text-decoration: underline;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, #ffffff 0%, #fef8f1 48%, #fff 100%);
  box-shadow: var(--shadow);
  border: 1px solid rgba(231, 222, 212, 0.8);
  margin-bottom: 18px;
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}

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

.tab {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 16px;
  background: #f4efe8;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
}

.tab.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  box-shadow: 0 8px 20px rgba(24, 20, 16, 0.18);
}

.topbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.notice {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 14px;
  margin-bottom: 16px;
}

.notice.info {
  background: #e7f3f6;
  border-color: #bfe2ea;
  color: #1b5b68;
}

.notice.success {
  background: #ecf9f2;
  border-color: #c3ead6;
  color: #1b6a42;
}

.notice.error {
  background: #fff0f3;
  border-color: #ffd2dc;
  color: #a11c3a;
}

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}

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

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: cardIn 0.5s ease both;
}

.grid > .card:nth-child(1) { animation-delay: 0.02s; }
.grid > .card:nth-child(2) { animation-delay: 0.05s; }
.grid > .card:nth-child(3) { animation-delay: 0.08s; }
.grid > .card:nth-child(4) { animation-delay: 0.11s; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.balance-card {
  background: linear-gradient(135deg, #fff6e6 0%, #fffdf8 45%, #f2f9fb 100%);
}

.balance-value {
  font-size: 32px;
  font-weight: 700;
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.balance-value .currency {
  font-size: 18px;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}

.field input,
.field select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #d8cec2;
  background: #fff;
  font-size: 14px;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 140, 0.15);
}

.form-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.inline-info {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f6f1ea;
  border: 1px dashed #d9cfc3;
  margin-top: 8px;
}

.inline-info .label,
.details-grid .label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 4px;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
}

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

.small {
  font-size: 12px;
}

.proof-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.proof-countdown {
  font-variant-numeric: tabular-nums;
}

.proof-countdown.is-live {
  color: #1a6d6a;
  font-weight: 600;
}

.proof-countdown.is-expired {
  color: #a11c3a;
  font-weight: 600;
}

.proof-countdown.is-frozen {
  color: #a11c3a;
}

.proof-countdown.is-final {
  color: #6b7280;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid #eadfd4;
  background: #fff;
}

.list-item.is-selected {
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(31, 122, 140, 0.18);
}

.list-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-title {
  font-weight: 600;
}

.list-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  text-align: right;
}

.active-order-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.active-order-transfers {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #ddcfbf;
  display: grid;
  gap: 8px;
  animation: expandDown 0.22s ease both;
}

.active-transfer-item {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #e7dacb;
  background: #fffaf4;
}

.active-transfer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.active-transfer-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  color: #5b4a3b;
  word-break: break-all;
}

.active-transfer-meta {
  margin-top: 6px;
  word-break: break-word;
}

.active-transfer-links {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.active-transfer-links a {
  font-size: 12px;
  font-weight: 700;
}

.active-transfer-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.pill.neutral {
  background: #f1ede7;
  color: #5c5147;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-created { background: #eaf2ff; color: #1c4fa1; border-color: #bcd3ff; }
.status-in-progress { background: #e7f7f6; color: #1a6d6a; border-color: #b4e6e3; }
.status-completed { background: #ecf9f2; color: #1b6a42; border-color: #bfe9d2; }
.status-wallet-pending { background: #fff8e7; color: #9a6a1a; border-color: #f2d7a3; }
.status-wallet-credited { background: #f2f5ff; color: #3945a6; border-color: #c7d1ff; }
.status-dispute { background: #fff0f3; color: #a11c3a; border-color: #ffd2dc; }
.status-canceled { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
.status-awaiting-proof { background: #eef6ff; color: #245399; border-color: #c9ddff; }
.status-awaiting-recipient { background: #f0fffb; color: #1c6f64; border-color: #bcebe3; }
.status-frozen { background: #fff0f3; color: #a11c3a; border-color: #ffd2dc; }
.status-confirmed { background: #ecf9f2; color: #1b6a42; border-color: #c3ead6; }
.status-cancelled { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }

button {
  border-radius: 999px;
  padding: 8px 14px;
  border: 1px solid #d7cfc4;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(28, 26, 22, 0.12);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary:hover:not(:disabled) {
  background: #186575;
}

.ghost {
  background: #f5efe8;
  color: #3d342c;
}

.danger {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #fff;
}

.input-inline {
  display: flex;
  gap: 10px;
}

.input-inline input {
  flex: 1;
}

.result-box {
  margin-top: 14px;
  padding: 12px;
  background: #f6f1ea;
  border-radius: 12px;
  border: 1px dashed #d9cfc3;
}

.details-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 12px;
}

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

.exchange-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

#exchangeReceive[readonly] {
  background: #f4efe8;
}

.table-wrap {
  border-radius: 14px;
  border: 1px solid #eadfd4;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #efe6dc;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f9f4ee;
  font-weight: 600;
}

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

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
  animation: fadeIn 0.4s ease both;
}

.hidden {
  display: none;
}

body.modal-open {
  overflow: hidden;
}

.instruction-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 14, 18, 0.62);
  z-index: 10001;
  padding: 16px;
}

.instruction-modal.hidden {
  display: none;
}

.instruction-modal-card {
  width: min(680px, 96vw);
  background: #fffdf9;
  border: 1px solid #dccdbd;
  border-radius: 16px;
  box-shadow: 0 20px 48px rgba(20, 18, 14, 0.35);
  padding: 20px 20px 18px;
}

.instruction-modal-card h3 {
  margin: 0 0 12px;
}

.instruction-modal-card p {
  margin: 0;
  color: #3f352c;
  line-height: 1.5;
}

.instruction-modal-actions {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.debug {
  margin-top: 18px;
  padding: 12px;
  background: #111827;
  color: #e5e7eb;
  border-radius: 12px;
  max-height: 220px;
  overflow: auto;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes expandDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .topbar-actions {
    justify-content: center;
  }

  .tabs {
    justify-content: center;
  }

  .list-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .list-meta {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
  }

  .list-row {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
  }

  .active-transfer-head {
    align-items: flex-start;
  }
}

body.auth-locked {
  overflow: hidden;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 14, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.auth-overlay.is-open {
  display: flex;
}

.auth-card {
  width: min(520px, 92vw);
  background: #1b1d24;
  color: #f3f2f0;
  border: 1px solid #2c2f3a;
  border-radius: 16px;
  padding: 18px 20px 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.auth-title {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #7ac7d4;
  margin-bottom: 12px;
}

.auth-mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.auth-mode-btn {
  border-radius: 10px;
  border: 1px solid #3a3f4d;
  background: #232734;
  color: #d8deea;
  padding: 9px 10px;
}

.auth-mode-btn.is-active {
  border-color: #1f7a8c;
  background: #1f7a8c;
  color: #fff;
}

.auth-label {
  font-size: 12px;
  color: #cdd3e1;
  margin: 10px 0 6px;
  display: block;
}

.auth-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #3a3f4d;
  background: #232734;
  color: #f3f2f0;
  outline: none;
}

.auth-input:focus {
  border-color: #7ac7d4;
  box-shadow: 0 0 0 3px rgba(122, 199, 212, 0.25);
}

.auth-btn {
  margin-top: 14px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #1f7a8c;
  background: #1f7a8c;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.auth-btn:hover {
  background: #186575;
}

.auth-hint {
  margin-top: 10px;
  font-size: 12px;
  color: #9ea8bc;
}

.auth-error {
  min-height: 18px;
  margin-top: 10px;
  color: #f4a6b5;
  font-size: 12px;
}
