/* escrow-v1 — Pulse Escrow holdings page. Self-contained per prototype principle. */

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ============ APP SHELL ============ */
.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 680px) 320px;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* ============ SIDEBAR ============ */
.sidebar { position: sticky; top: 24px; height: calc(100vh - 48px); display: flex; flex-direction: column; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 14px; font-size: 32px; font-weight: 800; margin-bottom: 36px; color: var(--text); }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.sidebar nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar nav a {
  padding: 14px 18px;
  color: var(--text-soft);
  border-radius: 999px;
  font-weight: 600;
  font-size: 16px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.sidebar nav a.active,
.sidebar nav a:hover {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-card);
}
.new-post {
  border-radius: 999px;
  background: var(--cta-bg);
  color: var(--cta-text);
  font-weight: 700;
  padding: 14px 22px;
  font-size: 16px;
}

/* ============ MAIN ============ */
.main { min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  min-height: 44px;
  gap: 12px;
}
.topbar .back {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  font-size: 22px;
  color: var(--text);
}
.topbar h1 { font-size: 28px; margin: 0; font-weight: 700; letter-spacing: -0.01em; flex: 1; }
.topbar-brand { display: none; align-items: center; gap: 8px; color: var(--text); font-weight: 800; font-size: 22px; letter-spacing: -0.01em; }
.topbar-brand img { width: 24px; height: 24px; object-fit: contain; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

/* ============ HERO ============ */
.escrow-hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: var(--radius-md);
  padding: 22px 22px 20px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}
.escrow-hero::after {
  content: "";
  position: absolute;
  right: -90px; top: -90px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255,255,255,0.16), transparent);
  pointer-events: none;
}
.hero-top { display: flex; align-items: center; gap: 14px; }
.hero-top .shield {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: rgba(255,255,255,0.18);
  display: grid; place-items: center;
  color: white;
  flex-shrink: 0;
}
.hero-top h2 { margin: 0; font-size: 18px; font-weight: 700; }
.hero-top p { margin: 4px 0 0; color: rgba(255,255,255,0.82); font-size: 13px; }

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}
.hero-stats .stat {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 14px;
  padding: 12px 8px;
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: background 0.15s, transform 0.05s;
}
.hero-stats .stat:hover { background: rgba(255,255,255,0.20); }
.hero-stats .stat:active { transform: scale(0.98); }
.hero-stats .num { font-size: 24px; font-weight: 800; line-height: 1; }
.hero-stats .lbl { font-size: 12px; opacity: 0.86; }

/* ============ TABS ============ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  gap: 2px;
}
.tab {
  padding: 12px 14px;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab.active { color: var(--text); border-color: var(--primary); }
.tab .badge {
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  min-width: 18px;
  text-align: center;
}
.tab.active .badge { background: var(--primary-soft); color: var(--primary-dark); }

/* ============ LIST ============ */
.esc-list { display: flex; flex-direction: column; gap: 12px; }

.esc-empty-hint {
  text-align: center;
  color: var(--text-soft);
  padding: 40px;
  font-size: 14px;
}

/* === Outgoing / Incoming card === */
.esc-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}
.esc-item .head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.esc-item .avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: white;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}
.esc-item .who { flex: 1; min-width: 0; }
.esc-item .who b { display: block; font-size: 15px; }
.esc-item .who small { display: block; color: var(--text-soft); font-size: 12px; }
.esc-item .ext-addr {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text-soft);
  word-break: break-all;
}

.esc-item .status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}
.esc-item .status-pill.wait-you { background: #fef3c7; color: #92400e; }
.esc-item .status-pill.wait-other { background: #cffafe; color: #155e75; }
.esc-item .status-pill.part { background: var(--primary-soft); color: var(--primary-dark); }

.esc-item .amount-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.esc-item .amount {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.esc-item .amount.gain { color: var(--success); }
.esc-item .amount-row .usd { color: var(--text-soft); font-size: 13px; }

.esc-item .note {
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  margin: 6px 0 4px;
}
.esc-item .meta {
  color: var(--text-soft);
  font-size: 12px;
  margin-bottom: 12px;
}

.esc-progress { margin: 2px 0 4px; }
.esc-progress .bar {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-soft);
  overflow: hidden;
}
.esc-progress .bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
}
.esc-progress small {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-soft);
}

.esc-item .actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.esc-item .actions button {
  flex: 1;
  padding: 11px 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.esc-item .actions .release {
  background: var(--primary);
  color: white;
}
.esc-item .actions .release:hover { background: var(--primary-dark); }
.esc-item .actions .cancel {
  background: var(--surface-soft);
  color: var(--text-soft);
}
.esc-item .actions .cancel:hover { background: #fee2e2; color: #991b1b; }

.esc-item .incoming-note {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text-soft);
  font-size: 12px;
  margin-top: 12px;
}
.esc-item .incoming-note svg { flex-shrink: 0; color: var(--info); }

/* === History row (compact) === */
.esc-history { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-card); }
.esc-history-row {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.esc-history-row:last-child { border-bottom: 0; }
.esc-history-row .ic {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
}
.esc-history-row .ic.released { background: rgba(16,185,129,0.12); color: var(--success); }
.esc-history-row .ic.cancelled { background: rgba(245,158,11,0.14); color: var(--warning); }
.esc-history-row .label { font-weight: 600; font-size: 14px; }
.esc-history-row .label small { display: block; color: var(--text-soft); font-weight: 500; font-size: 12px; margin-top: 2px; }
.esc-history-row .amt { font-weight: 700; text-align: right; font-size: 14px; }
.esc-history-row .amt.gain { color: var(--success); }
.esc-history-row .amt.loss { color: var(--warning); }
.esc-history-row .amt .unit { display: block; font-size: 11px; font-weight: 500; color: var(--text-soft); margin-top: 2px; }

/* ============ Avatar gradients (shared scheme) ============ */
.avatar.g1 { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.avatar.g2 { background: linear-gradient(135deg, #ec4899, #f97316); }
.avatar.g3 { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.avatar.g4 { background: linear-gradient(135deg, #10b981, #059669); }
.avatar.g5 { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.avatar.gx { background: linear-gradient(135deg, #6b7280, #374151); }

/* ============ RIGHT PANEL ============ */
.right-panel { display: flex; flex-direction: column; gap: 16px; }
.right-panel .card { padding: 20px; }
.right-panel h2 { font-size: 15px; margin: 0 0 12px; font-weight: 700; }

/* Flow steps (mirror send-v1's escrow detail look) */
.flow { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.flow li { display: flex; gap: 12px; align-items: flex-start; }
.flow .step {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}
.flow .step.ok { background: #d1fae5; color: #065f46; }
.flow .step.warn { background: #fed7aa; color: #9a3412; }
.flow .step.auto { background: #cffafe; color: #155e75; }
.flow li b { font-size: 13px; }
.flow li small { display: block; color: var(--text-soft); font-size: 12px; line-height: 1.5; margin-top: 2px; }
.flow b.penalty { color: var(--error); }

.tip-card ul { margin: 0; padding-left: 18px; color: var(--text-soft); font-size: 13px; line-height: 1.7; }
.tip-card li b { color: var(--text); }

.disclaim-card p { margin: 0; font-size: 13px; color: var(--text); }
.disclaim-card p + p { margin-top: 6px; }
.disclaim-card .muted { color: var(--text-soft); font-size: 12px; }

/* ============ MODALS ============ */
.modal {
  position: fixed; inset: 0;
  z-index: 50;
  display: grid; place-items: center;
  padding: 20px;
}
.modal[hidden] { display: none !important; }
.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-float);
  text-align: center;
}
.modal-card h3 { margin: 0 0 6px; font-size: 18px; }
.modal-card .sub { margin: 0 0 16px; color: var(--text-soft); font-size: 13px; }
.modal-card .sub .warn { color: var(--warning); }
.modal-target {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  text-align: left;
}
.modal-target .avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: white;
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
}
.modal-target b { display: block; font-size: 14px; }
.modal-target small { display: block; color: var(--text-soft); font-size: 12px; }

.modal-amount {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 8px 0 18px;
}
.modal-amount small { font-size: 14px; font-weight: 700; margin-left: 6px; color: var(--text-soft); }

.pct-chips {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
}
.pct-chips button {
  flex: 1;
  padding: 10px 0;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-weight: 700;
  font-size: 14px;
  color: var(--text-soft);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pct-chips button:hover { border-color: var(--primary); color: var(--primary-dark); }
.pct-chips button.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.cancel-breakdown {
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 0 0 18px;
  font-size: 13px;
}
.cancel-breakdown div {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}
.cancel-breakdown div[hidden] { display: none !important; }
.cancel-breakdown .muted span,
.cancel-breakdown .muted b { color: var(--text-soft); font-weight: 600; }
.cancel-breakdown .bad b { color: var(--error); }
.cancel-breakdown .ok b { color: var(--success); }

.modal-actions { display: flex; gap: 8px; }
.modal-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  background: var(--surface-soft);
  color: var(--text);
}
.modal-actions button.primary { background: var(--primary); color: white; }
.modal-actions button.primary:hover { background: var(--primary-dark); }
.modal-actions button.danger { background: var(--error); color: white; }
.modal-actions button.danger:hover { background: #dc2626; }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-float);
  z-index: 60;
  animation: toast-in 0.2s ease-out;
}
.toast[hidden] { display: none !important; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ BACK TO TOP ============ */
.to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 50;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--text);
  color: white;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.32);
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s, background 0.15s;
}
.to-top.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
@media (hover: hover) {
  .to-top:hover { background: var(--primary-dark); }
}
.to-top:active { transform: translateY(0) scale(0.94); }

/* ============ MOBILE NAV (pill style, consistent with other v1 pages) ============ */
.mobile-nav { display: none; }
.mobile-nav a.active { color: var(--text); font-weight: 600; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 240px minmax(0, 1fr); padding: 16px; gap: 18px; }
  .right-panel { display: none; }
}

@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; padding: 0; gap: 0; }
  .sidebar { display: none; }
  .main { padding: 14px 16px 80px; }
  .topbar { padding: 4px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
  .topbar .back { display: inline-flex; }
  .topbar h1 { font-size: 18px; text-align: center; }
  .topbar-brand { display: none; }
  .escrow-hero { padding: 18px; }
  .hero-top h2 { font-size: 16px; }
  .hero-stats .num { font-size: 20px; }
  .esc-item { padding: 14px; }
  .esc-item .amount { font-size: 18px; }

  /* Pill-style mobile nav (consistent with home / discover / wallet etc) */
  .mobile-nav {
    position: fixed;
    left: 12px; right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow-card);
    padding: 10px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 20;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
  }
  .mobile-nav.nav-hidden {
    transform: translateY(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
  }
  .mobile-nav a { text-align: center; font-size: 12px; color: var(--text-soft); padding: 8px 4px; }
  .mobile-nav .compose-btn {
    width: 46px; height: 46px;
    margin: auto; padding: 0;
    border-radius: 50%;
    background: var(--cta-bg); color: var(--cta-text);
    display: grid; place-items: center; line-height: 1;
  }

  /* to-top mobile position + sync to nav state */
  .to-top {
    bottom: 88px; right: 16px; width: 42px; height: 42px;
    transition: opacity 0.2s, transform 0.2s, background 0.15s,
                bottom 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }
  body.nav-hidden .to-top { bottom: 28px; }
}

/* === Spy 唯讀模式 === */
.spy-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--primary-soft, #eef2ff);
  color: var(--primary, #4f46e5);
  font-size: 13px;
}
.spy-pill {
  flex: none;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--primary, #4f46e5);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.spy-toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%) translateY(8px);
  padding: 10px 18px;
  border-radius: 999px;
  background: #1e293b;
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
}
.spy-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
