:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --bg: #080e1d;
  --surface: #0f172a;
  --surface2: #1a2540;
  --border: #1e3355;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent2: #6366f1;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  background: var(--bg);
  color: var(--text);
}

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

body {
  margin: 0;
  background: radial-gradient(ellipse at top left, #0d1b3e 0%, var(--bg) 55%);
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  background: #080e1dd8;
  z-index: 20;
}

.topbar-left { display: flex; align-items: center; gap: 0.75rem; }

.topbar-badge {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  border-radius: 8px;
  padding: 0.3rem 0.65rem;
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}

h1, h2, h3, p { margin: 0; }

.subtitle { color: var(--muted); font-size: 0.78rem; }

.clock {
  color: var(--muted);
  font-size: 0.82rem;
  font-family: 'Fira Code', monospace;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
}

/* ── Stats strip ── */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.5rem;
  padding: 0.75rem 1rem 0;
}

.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Layout ── */
.layout {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  padding: 0.75rem 1rem 2rem;
}

/* ── Panel ── */
.panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem;
  background: #0c1526cc;
  min-height: 160px;
}

.panel-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.65rem;
}

.stack {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.65rem;
}

/* ── Card ── */
.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  display: grid;
  gap: 0.45rem;
  background: var(--surface2);
  transition: border-color 0.15s;
}

.card:hover { border-color: #2a4070; }

/* ── Row / Tags ── */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.tag {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── State badges ── */
.state { font-weight: 700; font-size: 0.8rem; border-radius: 999px; padding: 0.15rem 0.55rem; }
.state-CREATED    { background: #1e3a5f; color: #93c5fd; }
.state-ACCEPTED   { background: #1a3a20; color: #86efac; }
.state-FUNDED     { background: #2d2a00; color: #fde68a; }
.state-PAID       { background: #3a1d00; color: #fed7aa; }
.state-COMPLETED  { background: #14532d; color: #4ade80; }
.state-REFUNDED   { background: #450a0a; color: #f87171; }
.state-DISPUTED   { background: #713f12; color: #fcd34d; }
.state-CANCELLED  { background: #1e293b; color: #64748b; }

/* ── Buttons / Inputs ── */
button, select, input, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

button {
  cursor: pointer;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

button:hover { border-color: var(--accent); background: #0f1e38; box-shadow: 0 0 0 2px #1e3a5f33; }

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

button.btn-primary:hover { background: #2563eb; box-shadow: 0 2px 10px rgba(59,130,246,0.35); }

button.btn-danger { border-color: var(--danger); color: var(--danger); }
button.btn-danger:hover { background: #7f1d1d33; }

textarea, input { width: 100%; }
select { width: 100%; }

/* ── Search bar ── */
.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}

.search-bar input, .search-bar select {
  width: auto;
  flex: 1;
  min-width: 0;
}

/* ── My Trades filter ── */
.my-trades-filter {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
  align-items: center;
}

.my-trades-filter select { flex: 1; min-width: 0; }

/* ── Reputation tiers ── */
.rep-tier {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
}

.rep-diamond { background: #dbeafe; color: #1e40af; }
.rep-gold    { background: #fef9c3; color: #713f12; }
.rep-silver  { background: #f1f5f9; color: #334155; }
.rep-bronze  { background: #fde8d8; color: #7c2d12; }
.rep-new     { background: var(--surface2); color: var(--muted); }

/* ── Rep score bar ── */
.rep-bar-track {
  height: 6px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.3rem 0;
  border: 1px solid var(--border);
}

.rep-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ── Activity log ── */
.logs ul, #activity-log {
  margin: 0.65rem 0 0;
  padding: 0 0 0 0.9rem;
  display: grid;
  gap: 0.15rem;
}

#activity-log li { font-size: 0.78rem; color: var(--muted); }
#activity-log li:first-child { color: var(--text); }

/* ── Metric grid ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem;
  font-size: 0.82rem;
}

small { color: var(--muted); font-size: 0.78rem; }
h2 { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.1rem; }
h3 { font-size: 0.88rem; font-weight: 700; }

/* ── Offer card — Binance P2P style ── */
.offer-card { gap: 0.6rem; }

.offer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.offer-seller {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.offer-seller-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.offer-seller-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.offer-seller-stats {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 1px;
}

.offer-price-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--border);
}

.offer-price {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--success);
  line-height: 1.1;
}

.offer-price-unit {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.offer-rate {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

.offer-fiat {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--warning);
  text-align: right;
}

.offer-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.offer-liquidity {
  padding-top: 0.25rem;
}

.offer-liquidity-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.offer-liq-track {
  height: 5px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.offer-liq-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.offer-action-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  margin-top: 0.15rem;
  flex-wrap: wrap;
}

.offer-action-label {
  font-size: 0.7rem;
  color: var(--muted);
  display: block;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.offer-buy-btn {
  padding: 0.5rem 1.1rem;
  font-size: 0.88rem;
  white-space: nowrap;
  align-self: flex-end;
}

.offer-buy-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
