/* =====================================================================
   P2P UI — unified modern skin (light + dark), cyan→green accent.
   Loaded LAST on P2P pages so it overrides the legacy stylesheets.
   Theme is driven by  html[data-theme="dark"]  (see partials/theme.php).
   ===================================================================== */

:root {
  --bg:          #eef2f7;
  --bg-grad:     radial-gradient(1200px 600px at 80% -10%, #e0f2fe 0%, transparent 60%), #eef2f7;
  --surface:     #ffffff;
  --surface-2:   #f4f7fb;
  --surface-3:   #eaeff6;
  --border:      #e2e8f0;
  --border-2:    #d7dfea;
  --text:        #0f172a;
  --text-soft:   #475569;
  --text-muted:  #748196;
  --accent:      #06b6d4;
  --accent-2:    #10b981;
  --accent-grad: linear-gradient(135deg, #06b6d4 0%, #10b981 100%);
  --accent-soft: rgba(6, 182, 212, .12);
  --danger:      #ef4444;
  --danger-soft: rgba(239, 68, 68, .12);
  --warning:     #f59e0b;
  --warning-soft:rgba(245, 158, 11, .14);
  --success:     #10b981;
  --success-soft:rgba(16, 185, 129, .14);
  --info:        #6366f1;
  --shadow:      0 4px 18px rgba(2, 8, 23, .08);
  --shadow-lg:   0 14px 40px rgba(2, 8, 23, .14);
  --radius:      16px;
  --radius-sm:   10px;
  --radius-pill: 999px;
  --glass-blur:  saturate(140%) blur(12px);
  /* aliases so legacy stylesheets (profile.css etc.) that use these names
     follow the same theme instead of their own body.light system */
  --card:        var(--surface);
  --muted:       var(--text-muted);
  /* Vision chart panel — kept dark in BOTH themes (a trading chart reads best
     dark; the page frames it via the themed .chart-container border). */
  --vchart-bg:   #0e1626;
  --vchart-grid: rgba(148,163,184,.16);
  --vchart-text: #94a3b8;
  /* consumed by traderoom.css — re-point its vars at our tokens so the trade
     room themes via data-theme (its own theme was keyed on dead body.dark). */
  --card-bg:          var(--surface);
  --border-color:     var(--border);
  --header-bg:        var(--surface-2);
  --header-color:     var(--text);
  --chat-self-bg:     var(--accent);
  --chat-self-color:  #ffffff;
  --chat-other-bg:    var(--surface-3);
  --chat-other-color: var(--text);
  --btn-bg:           var(--surface-2);
  --btn-color:        var(--text);
  --btn-active-bg:    var(--accent);
  --input-bg:         var(--surface-2);
  --input-color:      var(--text);
  --feedback-bg:      var(--surface-3);
  --feedback-color:   var(--text);
  --btn-primary-bg:   var(--accent);
  --btn-primary-color:#ffffff;
  --btn-success-bg:   var(--success);
  --btn-success-color:#ffffff;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg:          #070d18;
  --bg-grad:     radial-gradient(1100px 560px at 82% -12%, rgba(6,182,212,.16) 0%, transparent 58%),
                 radial-gradient(900px 480px at 8% 8%, rgba(16,185,129,.10) 0%, transparent 60%),
                 #070d18;
  --surface:     rgba(20, 31, 51, .82);
  --surface-2:   rgba(15, 24, 41, .9);
  --surface-3:   rgba(28, 41, 66, .9);
  --border:      rgba(94, 124, 170, .20);
  --border-2:    rgba(94, 124, 170, .32);
  --text:        #e8eff9;
  --text-soft:   #b7c5db;
  --text-muted:  #8295b2;
  --accent-soft: rgba(6, 182, 212, .18);
  --shadow:      0 8px 28px rgba(0, 0, 0, .45);
  --shadow-lg:   0 18px 50px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-grad) fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background .35s ease, color .35s ease;
  min-height: 100vh;
}

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

::selection { background: var(--accent-soft); }

/* custom scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 999px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- layout ---------- */
.container, .wrap {
  max-width: 1240px;
  margin: 1.4rem auto;
  padding: 0 1rem;
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  padding: .85rem 1.15rem;
  background: var(--surface);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 1px 0 var(--border);
}
.topbar strong { font-size: 1.05rem; letter-spacing: .2px; }
.nav-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.balance-strip {
  display: inline-flex;
  align-items: center;
  gap: .9rem;
  flex-wrap: wrap;
  padding: .5rem .9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: .82rem;
  color: var(--text-soft);
}
.balance-strip strong { color: var(--text); }

.toolbar { display: flex; align-items: center; gap: .55rem; }

/* theme toggle */
/* Theme toggles only — NOT a bare ".mode" (Vision's chart "Mode" button uses
   .vbtn.mode and must not be turned into a round icon button). */
#modeToggle, .theme-toggle, #themeToggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  transition: transform .15s ease, background .2s ease, border-color .2s ease;
  user-select: none;
}
#modeToggle:hover, .theme-toggle:hover, #themeToggle:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.theme-toggle { position: fixed; top: 14px; right: 14px; z-index: 60; box-shadow: var(--shadow); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .62rem 1.05rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: .9rem;
  line-height: 1.1;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease, border-color .2s ease;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn.small, .btn-small { padding: .42rem .75rem; font-size: .8rem; border-radius: 8px; }

.btn-primary, .btn.primary, .btn-post-offer, .text-primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 6px 16px rgba(6, 182, 212, .28);
}
.btn-primary:hover, .btn.primary:hover, .btn-post-offer:hover {
  box-shadow: 0 10px 22px rgba(6, 182, 212, .4); color: #fff;
}

.btn.ghost { background: transparent; color: var(--text-soft); border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }

.btn.outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn.outline:hover { background: var(--accent-soft); }

.btn.secondary { background: var(--surface-3); color: var(--text); border-color: var(--border); }

.btn.success, .btn.positive { background: var(--success); color: #fff; }
.btn.danger, .btn.red, .btn.negative { background: var(--danger); color: #fff; }
.btn.warning { background: var(--warning); color: #1f1300; }
.btn.info { background: var(--info); color: #fff; }

.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- alerts ---------- */
.alert {
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert.success, .alert-success { border-left-color: var(--success); background: var(--success-soft); }
.alert.error, .alert-error    { border-left-color: var(--danger);  background: var(--danger-soft); }
.alert.hidden { display: none; }

/* ---------- tabs ---------- */
.p2p-tabs, .order-status-tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--border);
  margin: 1rem 0 1.2rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.p2p-tabs::-webkit-scrollbar, .order-status-tabs::-webkit-scrollbar { display: none; }
.p2p-tabs .tab, .p2p-tabs a, .order-status-tabs a {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .7rem 1rem;
  white-space: nowrap;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .9rem;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: color .2s ease, border-color .2s ease;
}
.p2p-tabs .tab:hover, .order-status-tabs a:hover { color: var(--text); text-decoration: none; }
.p2p-tabs .tab.active, .order-status-tabs a.active {
  color: var(--accent);
  border-bottom-color: var(--accent-2);
}

.p2p-subtabs {
  display: inline-flex;
  gap: .25rem;
  padding: .3rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.p2p-subtabs a, .p2p-subtabs .tab {
  padding: .42rem .9rem;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .82rem;
  text-decoration: none;
}
.p2p-subtabs a.active, .p2p-subtabs .active {
  background: var(--accent-grad);
  color: #fff;
}
.p2p-subtabs.secondary { background: transparent; border: none; padding: 0; }
.p2p-subtabs.secondary a.active { background: var(--surface-3); color: var(--text); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  padding: .05rem .42rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .7rem;
  font-weight: 700;
}
.badge.red { background: var(--danger); color: #fff; }

/* order-status chips (Active/Completed/Cancelled/Disputed): legacy p2p.css
   hardcodes a #ccc border + #007bff active — theme them in both modes. */
.order-status-tabs a {
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-soft) !important;
  border-radius: var(--radius-pill);
  padding: .4rem .9rem;
}
.order-status-tabs a:hover { border-color: var(--accent) !important; color: var(--text) !important; }
.order-status-tabs a.active {
  background: var(--accent-grad) !important;
  color: #fff !important;
  border-color: transparent !important;
}
.order-status-tabs a.active .badge { background: rgba(255,255,255,.25); color: #fff; }

/* ---------- filters ---------- */
.market-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .7rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.2rem;
  box-shadow: var(--shadow);
}
.tx-filters { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* Filter-bar controls — override legacy p2p.css (which only darkened them under
   the now-unused body.dark, leaving white inputs invisible in dark mode). */
.market-filters input,
.market-filters select,
.tx-filters input,
.tx-filters select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .55rem .7rem;
  min-width: 140px;
}
.market-filters input::placeholder { color: var(--text-muted); }
.market-filters select option,
.tx-filters select option { background: var(--surface); color: var(--text); }
.market-filters .btn {
  background: var(--accent-grad);
  color: #fff;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
}

.my-offers-header { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* ---------- form controls ---------- */
input, select, textarea {
  font-family: inherit;
  font-size: .9rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .62rem .7rem;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }
label { font-size: .82rem; color: var(--text-soft); font-weight: 600; display: block; margin: .6rem 0 .25rem; }

/* ---------- cards / grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.1rem;
  align-items: stretch;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  transition: transform .2s ease, box-shadow .25s ease, border-color .2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-2); }
.card-header { display: flex; flex-direction: column; gap: .35rem; }
.card-header-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }

.price {
  font-size: 1.35rem;
  font-weight: 800;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -.3px;
}
.meta { font-size: .85rem; color: var(--text-soft); display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.range { font-size: .85rem; color: var(--text-muted); }
.user-link { color: var(--accent); font-weight: 600; }

.payments { margin-top: .55rem; display: flex; flex-wrap: wrap; gap: .35rem; }
.payments span {
  background: var(--surface-3);
  color: var(--text-soft);
  padding: .22rem .55rem;
  border-radius: 7px;
  font-size: .76rem;
  font-weight: 600;
}

.actions { display: flex; flex-direction: column; gap: .55rem; margin-top: .9rem; }
.actions.owner-actions { flex-direction: row; flex-wrap: wrap; }
.trade-amount { width: 100%; }
.approx-conversion { font-size: .8rem; color: var(--text-muted); }

/* ---------- transaction list ---------- */
.tx-list-container, .wallet-box { margin-top: 1rem; }
.tx-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.tx-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "left amount" "left time";
  align-items: center;
  gap: .15rem .8rem;
  padding: .85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .2s ease, transform .15s ease;
}
.tx-row:hover { border-color: var(--border-2); transform: translateX(2px); }
/* unread rows: legacy p2p.css forces `background:#f1f5ff !important` (white in
   dark mode) — override with our own !important themed rule. */
.tx-row.unread,
.tx-list .tx-row.unread {
  background: var(--surface-3) !important;
  color: var(--text);
  border-left: 3px solid var(--accent);
}
.tx-row.unread strong,
.tx-row.unread .tx-title { color: var(--text); }
.tx-left { grid-area: left; display: flex; flex-direction: column; gap: .15rem; }
.tx-title { font-weight: 600; font-size: .9rem; }
.tx-ref { color: var(--text-muted); font-size: .75rem; }
.tx-amount { grid-area: amount; font-weight: 700; font-size: .95rem; text-align: right; }
.tx-amount.in { color: var(--success); }
.tx-amount.out { color: var(--danger); }
.tx-time { grid-area: time; color: var(--text-muted); font-size: .72rem; text-align: right; }
.msg-badge {
  background: var(--danger); color: #fff; border-radius: var(--radius-pill);
  font-size: .65rem; font-weight: 700; padding: .05rem .4rem; margin-left: .35rem;
}

/* ---------- wallet box ---------- */
.wallet-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
}
.wallet-header { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.wallet-balances { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.wallet-balances .bal {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  font-weight: 700;
}

/* ---------- empty states ---------- */
.empty-state, .empty-wallet {
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem 1rem;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ---------- modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  padding: 1rem;
  background: rgba(2, 8, 23, .55);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
/* Shown states: index.php sets inline display:flex; trade_room.php adds .show.
   The base rule above keeps every modal hidden until one of those fires. */
.modal.show { display: flex; }
.modal.hidden { display: none; }
.modal-content, .modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content.small { max-width: 380px; }
.modal-buttons { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; }
.close {
  position: absolute; top: .7rem; right: .9rem;
  cursor: pointer; font-size: 1.4rem; line-height: 1; color: var(--text-muted);
  background: none; border: none;
}
.close:hover { color: var(--text); }
.balance-hint { font-size: .8rem; color: var(--text-muted); margin: .3rem 0; }
.inline-error, .field-error { color: var(--danger); font-size: .78rem; margin-top: .25rem; min-height: 1em; }
.max-row { display: flex; gap: .5rem; align-items: center; }
.max-row input { flex: 1; }

/* =====================================================================
   TRADE ROOM
   ===================================================================== */
.trade-room {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1.1rem;
  max-width: 1240px;
  margin: 1.2rem auto;
  padding: 0 1rem;
  align-items: start;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 140px);
  min-height: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.chat-header {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.chat-user-link { display: flex; align-items: center; gap: .6rem; color: var(--text); }
.user-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-grad); color: #fff; font-weight: 700;
}
.user-name-status { display: flex; flex-direction: column; line-height: 1.2; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: .35rem; }
.status-dot.online { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.status-dot.offline { background: var(--text-muted); }
.last-seen { font-size: .74rem; color: var(--text-muted); }
.trade-ref { font-size: .78rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: .3rem; }

.status-pill {
  display: inline-flex; align-items: center;
  padding: .25rem .7rem; border-radius: var(--radius-pill);
  font-size: .74rem; font-weight: 700; text-transform: capitalize;
  background: var(--surface-3); color: var(--text-soft);
}
.status-initiated { background: var(--surface-3); color: var(--text-soft); }
.status-escrowed  { background: var(--accent-soft); color: var(--accent); }
.status-paid      { background: var(--warning-soft); color: var(--warning); }
.status-released  { background: var(--success-soft); color: var(--success); }
.status-cancelled { background: var(--danger-soft); color: var(--danger); }
.status-disputed  { background: var(--danger-soft); color: var(--danger); }

.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 1rem; display: flex; flex-direction: column; gap: .6rem;
  background: var(--surface-2);
}
/* message bubbles */
/* The bubble is the .self/.other CONTAINER (traderoom.css styles it too, so use
   !important to win). message-content stays transparent — no double-bubble. */
.chat-messages .self, .chat-messages .other {
  max-width: 78%; padding: .55rem .85rem; border-radius: 16px;
}
.chat-messages .self {
  align-self: flex-end;
  background: var(--accent-grad) !important; color: #fff !important;
  border-bottom-right-radius: 4px;
}
.chat-messages .other {
  align-self: flex-start;
  background: var(--surface-3) !important; color: var(--text) !important;
  border: 1px solid var(--border); border-bottom-left-radius: 4px;
}
.chat-messages .self .message-content,
.chat-messages .other .message-content {
  background: none !important; border: none; padding: 0; margin: 0;
  font-size: .9rem; line-height: 1.35; word-break: break-word; color: inherit;
}
.chat-messages .username { font-size: .72rem; color: var(--text-muted); margin-bottom: .15rem; font-weight: 600; }
.msg-time { font-size: .66rem; color: var(--text-muted); margin-top: .2rem; }
.chat-messages .self .msg-time { text-align: right; }

.chat-system {
  align-self: center; max-width: 90%;
  text-align: center; font-size: .8rem; color: var(--text-soft);
  background: var(--surface-3); border: 1px solid var(--border);
  padding: .5rem .85rem; border-radius: var(--radius-pill);
}
.chat-system .highlight { color: var(--accent); font-weight: 700; }
.chat-moderator {
  align-self: center; max-width: 92%;
  background: var(--warning-soft); border: 1px solid var(--warning);
  color: var(--text); padding: .6rem .9rem; border-radius: 12px; font-size: .85rem;
}
/* feedback pill (in chat + summary) — themed, visible in both modes */
.feedback-type {
  display: inline-block;
  padding: .12rem .55rem;
  border-radius: var(--radius-pill);
  font-size: .74rem;
  font-weight: 700;
  white-space: nowrap;
}
.feedback-type.positive { background: var(--success-soft); color: var(--success); }
.feedback-type.negative { background: var(--danger-soft);  color: var(--danger); }

/* leave-feedback card */
.feedback-card { display: flex; flex-direction: column; gap: .6rem; }
.feedback-card h4 { margin: 0; font-size: .95rem; }
.feedback-card textarea { width: 100%; }
.feedback-buttons { display: flex; gap: .5rem; }
.feedback-buttons .btn { flex: 1; }
/* neutral by default; fill + color only when selected (.active) */
.feedback-buttons .btn.positive,
.feedback-buttons .btn.negative {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}
.feedback-buttons .btn.positive.active {
  background: var(--success) !important; color: #fff !important; border-color: transparent !important;
}
.feedback-buttons .btn.negative.active {
  background: var(--danger) !important; color: #fff !important; border-color: transparent !important;
}
.doc-placeholder, .doc-upload, .doc-preview {
  background: var(--surface); border: 1px dashed var(--border-2);
  padding: .55rem .8rem; border-radius: 10px; font-size: .82rem;
}

.chat-input {
  display: flex; gap: .55rem; align-items: center;
  padding: .75rem; border-top: 1px solid var(--border); background: var(--surface);
}
.chat-input input, .chat-input textarea { flex: 1; }
.chat-input button { flex-shrink: 0; }

/* info panel */
.info-panel { display: flex; flex-direction: column; gap: 1rem; }
.info-panel .card { padding: 1.05rem; }
.info-panel .row { display: flex; justify-content: space-between; gap: .8rem; padding: .35rem 0; font-size: .88rem; color: var(--text-soft); }
.info-panel .row strong { color: var(--text); }
.info-panel .row.total { border-top: 1px solid var(--border); margin-top: .35rem; padding-top: .6rem; font-weight: 700; }
.terms-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .7rem .85rem; font-size: .85rem; color: var(--text-soft); white-space: pre-wrap; }

.moderator-panel { border: 1px solid var(--warning); background: var(--warning-soft); }
.trade-action { display: flex; flex-direction: column; gap: .5rem; }
.trade-action .btn { width: 100%; }

.trade-dispute {
  display: flex; align-items: center; gap: .6rem;
  padding: .8rem 1rem; border-radius: var(--radius-sm);
  font-size: .86rem; margin: .6rem 0;
  background: var(--surface-2); border: 1px solid var(--border);
}
.trade-dispute .icon { font-size: 1.1rem; }
.trade-dispute.disputed { background: var(--danger-soft); border-color: var(--danger); }
.trade-dispute.cancelled { background: var(--surface-3); color: var(--text-muted); }
.trade-dispute.success { background: var(--success-soft); border-color: var(--success); }
.trade-dispute.error { background: var(--danger-soft); border-color: var(--danger); }
.dispute-link { color: var(--accent); font-weight: 600; }

.trade-timer { display: flex; align-items: center; justify-content: center; padding: .5rem; }
.trade-timer.paused { opacity: .55; }

/* =====================================================================
   DISPUTE UPLOAD PAGE
   ===================================================================== */
.dispute-box {
  max-width: 560px; margin: 2.5rem auto; padding: 1.6rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.dispute-box h3 { margin-top: 0; }
.note { font-size: .85rem; color: var(--text-muted); line-height: 1.45; }
.file-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 12px; margin-top: 1rem; }
.preview-item { border: 1px solid var(--border); border-radius: 10px; padding: 6px; text-align: center; font-size: .72rem; background: var(--surface-2); }
.preview-item img { width: 100%; height: 80px; object-fit: cover; border-radius: 7px; }
.preview-pdf { height: 80px; display: flex; align-items: center; justify-content: center; background: var(--danger-soft); color: var(--danger); font-weight: 700; border-radius: 7px; }
.preview-name { margin-top: 4px; word-break: break-word; color: var(--text-muted); }
input[type=file] { width: 100%; padding: .6rem; cursor: pointer; }

/* =====================================================================
   PUBLIC PROFILE PAGE (ftd/utdx_profile.php)
   ===================================================================== */
.page-wrapper { max-width: 1100px; margin: 1.4rem auto; padding: 0 1rem; }

.top-nav { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
/* keep the theme toggle inline in the nav (not fixed) so it can't overlap the buttons */
.top-nav .theme-toggle { position: static; margin-left: auto; box-shadow: none; }
.top-nav button, .top-nav a {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .5rem .9rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-weight: 600; font-size: .85rem; cursor: pointer; text-decoration: none;
  transition: border-color .2s ease, transform .12s ease;
}
.top-nav button:hover, .top-nav a:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }

.profile-header {
  display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
.profile-header h2 { margin: 0 0 .5rem; font-size: 1.25rem; display: flex; align-items: center; gap: .4rem; }
.avatar {
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.stats { display: flex; gap: .5rem; flex-wrap: wrap; }
.stat {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .35rem .7rem; border-radius: var(--radius-pill);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: .82rem; font-weight: 600; color: var(--text-soft);
}
.stat svg { width: 18px; height: 18px; }
.stat svg { stroke: var(--accent); }
.stat.negative svg { stroke: var(--danger); }

.status {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .7rem; border-radius: var(--radius-pill);
  font-size: .76rem; font-weight: 700; margin-top: .9rem;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.online { background: var(--success-soft); color: var(--success); }
.status.offline { background: var(--surface-3); color: var(--text-muted); }
.last-active { font-size: .76rem; color: var(--text-muted); margin-left: .5rem; }

/* profile tabs (uses .tabs, not .p2p-tabs) */
.tabs {
  display: flex; gap: .25rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin: 1rem 0 .5rem;
}
.tabs .tab {
  padding: .6rem 1rem; cursor: pointer;
  color: var(--text-muted); font-weight: 600; font-size: .9rem;
  border-bottom: 2px solid transparent; background: transparent;
}
.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--accent); border-bottom-color: var(--accent-2); }
hr { border: none; border-top: 1px solid var(--border); margin: .75rem 0 1rem; }

.cards-container { margin-top: 1rem; background: transparent; border: none; padding: 0; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}
/* offer + "trades with you" cards — explicit theming + a clear border so they
   stay visible on the light theme (white card on a near-white page). */
.cards .card {
  display: flex; flex-direction: column; gap: .35rem;
  background: var(--surface) !important;
  border: 1px solid var(--border-2);
  color: var(--text);
}
.cards .card > div { color: var(--text); }
.card .asset { font-size: 1.05rem; font-weight: 800; letter-spacing: .3px; color: var(--text); }
.card .limit, .card .meta, .card .margin { font-size: .82rem; color: var(--text-soft); }
.card .payment { font-size: .8rem; color: var(--text-muted); }
.amount-input { width: 100%; margin: .5rem 0; }
.card .buttons { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .35rem; }
.card .buttons .btn { flex: 1; }
.badge {
  align-self: flex-start;
  background: var(--accent-soft); color: var(--accent);
}

/* recent-trades mini cards (ajax_offer_recent_trades.php) */
.mini-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .7rem .85rem; margin-bottom: .6rem;
}
.mini-card .top { display: flex; align-items: center; gap: .4rem; font-size: .9rem; }
.mini-card .rate { color: var(--text-muted); font-size: .8rem; }
.mini-card .with { font-size: .82rem; color: var(--text-soft); margin-top: .25rem; }
.mini-card .comment { font-size: .82rem; margin-top: .4rem; padding: .35rem .55rem; border-radius: 8px; background: var(--surface-3); }
.mini-card .comment.positive { color: var(--success); }
.mini-card .comment.negative { color: var(--danger); }
.mini-card .comment.muted { color: var(--text-muted); }

/* =====================================================================
   AUTH PAGES (auth/signin.php, auth/register.php)
   ===================================================================== */
.auth-wrapper {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
.auth-card h1 { margin: 0 0 .25rem; font-size: 1.5rem; letter-spacing: -.4px; }
.auth-card .subtitle { margin: 0 0 1.3rem; color: var(--text-muted); font-size: .9rem; }

.input-group { margin-bottom: 1rem; }
.input-group label { display: block; margin-bottom: .35rem; font-size: .82rem; font-weight: 600; color: var(--text-soft); }
.input-group input,
.input-group select { width: 100%; }
.password-group { position: relative; }
.password-group .eye {
  position: absolute; right: .7rem; top: 50%; transform: translateY(20%);
  cursor: pointer; opacity: .7; user-select: none;
}
.password-group .eye:hover { opacity: 1; }

.password-meter { height: 6px; background: var(--surface-3); border-radius: var(--radius-pill); overflow: hidden; margin-top: .45rem; }
.meter-bar { height: 100%; width: 0; background: var(--accent-grad); border-radius: var(--radius-pill); transition: width .3s ease; }

.remember { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--text-soft); margin: .2rem 0 1rem; }
.muted { color: var(--text-muted); font-size: .82rem; }
.link, .link-btn {
  color: var(--accent); font-weight: 600; cursor: pointer;
  background: none; border: none; padding: 0; font-size: inherit; text-decoration: none;
}
.link:hover, .link-btn:hover { text-decoration: underline; }

/* auth submit button: full width + loading spinner */
.auth-card .btn-primary {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1rem; margin-top: .4rem;
  border: none; border-radius: var(--radius-sm);
  background: var(--accent-grad); color: #fff; font-weight: 700; font-size: .95rem;
  cursor: pointer; box-shadow: 0 6px 16px rgba(6,182,212,.28);
  transition: box-shadow .2s ease, transform .12s ease, opacity .2s ease;
}
.auth-card .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(6,182,212,.4); }
.auth-card .btn-primary:disabled { opacity: .7; cursor: default; transform: none; }
.spinner {
  display: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.45); border-top-color: #fff;
  animation: p2p-spin .6s linear infinite;
}
.btn-primary.loading .spinner { display: inline-block; }
.btn-primary.loading .btn-text { display: none; }
@keyframes p2p-spin { to { transform: rotate(360deg); } }

.footer-text { margin-top: 1.3rem; text-align: center; color: var(--text-muted); font-size: .88rem; }
.footer-text a { color: var(--accent); font-weight: 600; }
.google-btn {
  width: 100%;
  display: inline-flex !important; align-items: center; justify-content: center; gap: .6rem;
  margin: .4rem 0 1rem;
  padding: .7rem 1rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  font-weight: 600; text-decoration: none;
}
.google-btn:hover { border-color: var(--accent); text-decoration: none; }
.google-logo { width: 18px; height: 18px; }
.alert.warning { border-left-color: var(--warning); background: var(--warning-soft); }

/* Modals that are shown by removing .hidden (no .show class) — auth verify
   (.modal-box) and the wallet confirm (.modal-card). Re-enable their display
   without affecting modals that use inline display / .show. */
.modal:has(.modal-box):not(.hidden),
.modal:has(.modal-card):not(.hidden) { display: flex; }

/* wallet transfer USD preview + Max button spacing */
.preview { margin-top: .5rem; font-size: .85rem; color: var(--text-muted); font-weight: 600; }
#transferForm .btn { margin-top: .7rem; }

/* auth verification modal box */
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.modal-box input {
  width: 100%; text-align: center; letter-spacing: .3em;
  font-size: 1.1rem; margin: .8rem 0;
}
.modal-box button:not(.link-btn) {
  width: 100%; padding: .7rem; border: none; border-radius: var(--radius-sm);
  background: var(--accent-grad); color: #fff; font-weight: 700; cursor: pointer;
}
.modal-box button:disabled { opacity: .6; cursor: default; }

/* =====================================================================
   ADMIN — P2P dispute dashboard (admin/p2p/index.php)
   ===================================================================== */
.admin-wrap { max-width: 1200px; margin: 1.4rem auto; padding: 0 1rem; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.admin-topbar .theme-toggle { position: static; box-shadow: none; }
.admin-wrap h2, .admin-wrap h3 { color: var(--text); }

.admin-wrap .admin-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  margin-bottom: 1.5rem; font-size: .88rem;
}
.admin-wrap .admin-table th,
.admin-wrap .admin-table td {
  padding: .65rem .75rem; text-align: left; border-bottom: 1px solid var(--border);
}
.admin-wrap .admin-table thead th {
  background: var(--surface-2); color: var(--text-muted);
  font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .3px;
}
.admin-wrap .admin-table td { color: var(--text); }
.admin-wrap .admin-table tbody tr:hover { background: var(--surface-2); }
.admin-wrap .admin-table tr.row-danger { background: var(--danger-soft); }
.admin-wrap .admin-table select { padding: .35rem .5rem; min-width: 130px; }

.admin-wrap .filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.admin-wrap .card.danger { border-left: 4px solid var(--danger); }
.admin-wrap .card.warn   { border-left: 4px solid var(--warning); }
.admin-wrap .card b { display: inline-block; margin-top: .35rem; font-size: 1.7rem; font-weight: 800; }

@media (max-width: 760px) {
  .admin-wrap .admin-table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* =====================================================================
   VISION (vision_v2.php) — responsive chrome + inline theme toggle
   ===================================================================== */
.vision-wrapper {
  max-width: 1200px; margin: 0 auto; padding: 0 .8rem 2rem;
  width: 100%; box-sizing: border-box; overflow-x: hidden;  /* no page-level pinch on mobile */
}
.vision-topbar { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.vision-auth-btns { display: inline-flex; gap: .5rem; }
.vision-info, .vision-controls, .vision-session { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; max-width: 100%; }
.vision-session .stat { flex: 1 1 auto; min-width: 84px; }
.vision-history { max-width: 100%; overflow-x: auto; }       /* 7-col table scrolls itself */
.vision-history .history-head { min-width: 520px; }

/* info row under the chart (FUSED PRICE / Execution Duration / caption) */
#priceBox { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem 1rem; }
#priceBox #currentPrice { font-size: 1.35rem; font-weight: 800; }
#priceBox label { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
#priceBox small { color: var(--text-muted); font-size: .72rem; letter-spacing: .3px; }
@media (max-width: 640px) {
  #priceBox { width: 100%; gap: .4rem .7rem; }
  #priceBox label { width: 100%; }
  #priceBox label select { flex: 1; min-width: 0; }
  #priceBox small { width: 100%; opacity: .75; }
}
.vision-chart-controls { display: flex; flex-wrap: wrap; gap: .6rem .9rem; align-items: center; }
.vision-chart-controls label { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
/* spread the controls across the available width on desktop (no left-cramming) */
@media (min-width: 900px) { .vision-chart-controls { justify-content: space-between; } }
.chart-container {
  width: 100%; position: relative; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--vchart-bg);
}
#visionCanvas { display: block; max-width: 100%; background: var(--vchart-bg); }
@media (max-width: 640px) {
  .vision-chart-controls label { font-size: .78rem; }
  .vision-chart-controls select, .vision-chart-controls .vbtn { padding: .35rem .55rem; font-size: .8rem; }
  .vision-info small, .vision-controls small { font-size: 11px; }
  .vision-controls button { flex: 1 1 auto; }
  .vision-session .stat { flex: 1 1 30%; }
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 900px) {
  .trade-room { grid-template-columns: 1fr; }
  .chat-panel { height: 70dvh; }
  .info-panel { order: -1; }   /* show trade details above chat on mobile */
}

@media (max-width: 640px) {
  .container, .wrap { margin: 1rem auto; padding: 0 .8rem; }
  .topbar { padding: .7rem .9rem; }
  .balance-strip { width: 100%; justify-content: space-between; }
  .grid { grid-template-columns: 1fr; gap: .9rem; }
  .actions.owner-actions { flex-direction: column; }
  .actions.owner-actions .btn { width: 100%; }
  .price { font-size: 1.2rem; }
  .modal-content, .modal-card { padding: 1.1rem; }
  .chat-messages .self, .chat-messages .other { max-width: 88%; }
  .my-offers-header { flex-direction: column; align-items: stretch; }
  .my-offers-header .btn { width: 100%; }
  .profile-header { gap: .8rem; padding: 1rem; }
  .avatar { width: 60px; height: 60px; }
  .cards { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .nav-actions .btn { padding: .38rem .6rem; font-size: .76rem; }
  .balance-strip { font-size: .76rem; gap: .5rem; }
}

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
