/* USDT P2P — interface styles. Mobile first, right-to-left, light & dark. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #5b6b7f;
  --border: #e2e8f0;
  --primary: #0e8f6f;
  --primary-strong: #0a7359;
  --primary-soft: #e6f6f1;
  --on-primary: #ffffff;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --warning: #b45309;
  --warning-soft: #fff4e0;
  --info: #1d5fbf;
  --info-soft: #e8f0fd;
  --success: #15803d;
  --success-soft: #e7f6ec;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Segoe UI", Tahoma, "Noto Kufi Arabic", "Noto Sans Arabic", "Geeza Pro", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #111a2b;
    --surface-2: #0f1727;
    --text: #e6edf6;
    --muted: #93a4ba;
    --border: #1f2c42;
    --primary: #2bb58f;
    --primary-strong: #3fcaa3;
    --primary-soft: #0f2d27;
    --on-primary: #04130f;
    --danger: #f26b6b;
    --danger-soft: #3a1618;
    --warning: #f0a93b;
    --warning-soft: #3a2a10;
    --info: #6aa6ff;
    --info-soft: #132540;
    --success: #4ccf7f;
    --success-soft: #10301d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: .9em; direction: ltr; unicode-bidi: embed; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
.break { word-break: break-all; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 460px; margin-inline: auto; }
main { flex: 1; padding: 24px 0 48px; }

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.site-header .container { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; font-weight: 800; font-size: .9rem;
}
.nav { margin-inline-start: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a, .nav button.link {
  color: var(--text); padding: 8px 12px; border-radius: 10px; font-size: .95rem;
  background: none; border: 0; cursor: pointer; font: inherit;
}
.nav a:hover, .nav button.link:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--primary); font-weight: 600; }
.nav form { margin: 0; }
.nav .badge-count {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: .75rem; line-height: 20px; text-align: center; margin-inline-start: 4px;
}
.nav-toggle { display: none; }

@media (max-width: 720px) {
  .nav-toggle {
    display: inline-flex; margin-inline-start: auto; background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text); border-radius: 10px; padding: 6px 12px; font: inherit; cursor: pointer;
  }
  .nav { display: none; position: absolute; inset-inline: 0; top: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
    flex-direction: column; align-items: stretch; padding: 8px 16px 16px; }
  .nav.open { display: flex; }
  .nav a, .nav button.link { padding: 12px; text-align: start; width: 100%; }
}

.site-footer { border-top: 1px solid var(--border); padding: 20px 0; color: var(--muted); font-size: .9rem; background: var(--surface); }

/* ---------- Cards & grids ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .label { color: var(--muted); font-size: .9rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; direction: ltr; text-align: end; }
.stat .value small { font-size: .9rem; font-weight: 500; }
.stat.primary { background: linear-gradient(135deg, var(--primary), var(--primary-strong)); color: var(--on-primary); border: 0; }
.stat.primary .label { color: inherit; opacity: .9; }

/* ---------- Page header ---------- */
.page-head { margin-bottom: 20px; }
.page-head p { color: var(--muted); margin: 0; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
.field .hint { font-size: .85rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 1rem;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type=email], input[type=tel], input.ltr-input { direction: ltr; text-align: right; }
textarea { min-height: 90px; resize: vertical; }
.phone-row { display: grid; grid-template-columns: 150px 1fr; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; }
.check input { margin-top: 5px; width: 18px; height: 18px; flex: none; accent-color: var(--primary); }
.code-input {
  font-family: var(--mono); font-size: 1.8rem !important; letter-spacing: .5em; text-align: center !important;
  direction: ltr; padding: 14px !important;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .98rem; cursor: pointer; text-decoration: none !important;
  background: var(--surface-2); color: var(--text); border-color: var(--border);
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .88rem; }
.btn-link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Alerts & badges ---------- */
.alert { border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px; border: 1px solid transparent; font-size: .95rem; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert strong { display: block; margin-bottom: 2px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; background: var(--surface); }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; color: var(--muted); font-size: .85rem; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { direction: ltr; text-align: end; font-family: var(--mono); white-space: nowrap; }
.pos { color: var(--success); }
.neg { color: var(--danger); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; word-break: break-word; }

/* ---------- Home ---------- */
.hero { text-align: center; padding: 32px 0 12px; }
.hero h1 { font-size: 2rem; }
.hero p { color: var(--muted); font-size: 1.1rem; max-width: 640px; margin: 0 auto 20px; }
.feature { display: flex; gap: 14px; }
.feature .icon {
  flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-size: 1.3rem;
}
.feature h3 { margin-bottom: 4px; }
.feature p { color: var(--muted); margin: 0; font-size: .95rem; }

/* ---------- Steps ---------- */
.steps { display: flex; gap: 8px; margin-bottom: 16px; }
.steps span { flex: 1; height: 5px; border-radius: 5px; background: var(--border); }
.steps span.done { background: var(--primary); }
.checklist { list-style: none; padding: 0; margin: 0 0 16px; }
.checklist li { padding: 6px 0; padding-inline-start: 28px; position: relative; }
.checklist li::before { content: "✓"; position: absolute; inset-inline-start: 0; color: var(--primary); font-weight: 700; }

/* ---------- Admin ---------- */
.admin-shell { display: grid; grid-template-columns: 230px 1fr; gap: 20px; align-items: start; }
.admin-nav { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; position: sticky; top: 76px; }
.admin-nav a { display: flex; justify-content: space-between; padding: 10px 12px; border-radius: 10px; color: var(--text); }
.admin-nav a:hover { background: var(--surface-2); text-decoration: none; }
.admin-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav { position: static; display: flex; overflow-x: auto; gap: 4px; padding: 6px; }
  .admin-nav a { white-space: nowrap; }
}
.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.check-list li:last-child { border: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select { width: auto; flex: 1 1 160px; }
.hash { font-family: var(--mono); font-size: .8rem; direction: ltr; word-break: break-all; color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 24px; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb0 { margin-bottom: 0; }
.justify-center { justify-content: center; }
.page-center { margin: 40px auto; }

/* ---------- Lists (mobile-friendly rows) ---------- */
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.list-item { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .title { font-weight: 600; }
.list-item .meta { color: var(--muted); font-size: .85rem; }
.list-item details { margin-top: 8px; }
.list-item summary { cursor: pointer; color: var(--danger); font-size: .9rem; width: fit-content; }
.list-item details form { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.list-item details input { flex: 1 1 180px; }
.stat.primary .value small { color: inherit; opacity: .85; }
.destination { display: block; font-weight: 600; color: var(--text); margin-top: 2px; text-align: right; }

/* ---------- Wallet ---------- */
.narrow-lg { max-width: 640px; margin-inline: auto; }
.mb-16 { margin-bottom: 16px; }
.text-start { text-align: start; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
legend { font-weight: 600; margin-bottom: 6px; font-size: .95rem; padding: 0; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.choice {
  display: flex; gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; cursor: pointer; background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.choice input { accent-color: var(--primary); width: 18px; height: 18px; flex: none; margin: 0; }
.choice small { display: block; color: var(--muted); font-size: .8rem; }
.choice:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.choice.disabled { opacity: .5; cursor: not-allowed; }
.deposit-card { text-align: center; }
.deposit-step { padding: 8px 0 16px; border-bottom: 1px dashed var(--border); margin-bottom: 16px; }
.deposit-amount { font-size: 2.3rem; font-weight: 800; font-family: var(--mono); margin: 6px 0 10px; direction: ltr; line-height: 1.2; word-break: break-all; }
.deposit-amount small { font-size: 1rem; font-weight: 600; color: var(--muted); }
.qr { display: grid; place-items: center; width: 212px; height: 212px; margin: 12px auto; background: #fff; padding: 14px; border-radius: 14px; border: 1px solid var(--border); }
.qr img, .qr canvas { display: block; max-width: 100%; height: auto; }
.address-box {
  display: block; font-family: var(--mono); direction: ltr; text-align: center; word-break: break-all; background: var(--surface-2);
  border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin: 8px 0; font-size: .92rem; color: var(--text);
}
.address-box.inline { display: inline-block; margin: 0; padding: 4px 8px; text-align: left; font-size: .85rem; }
.deposit-status {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px; border-radius: var(--radius-sm);
  background: var(--info-soft); color: var(--info); margin-top: 4px;
}
.pulse { width: 11px; height: 11px; border-radius: 50%; background: currentColor; display: inline-block; vertical-align: middle; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }
.countdown { font-family: var(--mono); font-weight: 700; direction: ltr; display: inline-block; }
.summary-title { cursor: pointer; font-weight: 600; }
.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row input { flex: 1; min-width: 0; }
.summary-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px; }
.summary-box div { display: flex; justify-content: space-between; gap: 12px; }
.lead-amount { font-size: 1.1rem; font-weight: 600; }
.mono-input { font-family: var(--mono); font-size: .92rem !important; }
.wallet-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.stat.primary .wallet-actions .btn { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .35); color: inherit; }
.state-ok { color: var(--success); }
.state-bad { color: var(--danger); }
ol.steps-list { margin: 0; padding-inline-start: 22px; }
ol.steps-list li { margin-bottom: 6px; }
a.stat { display: block; color: var(--text); }
a.stat:hover { text-decoration: none; border-color: var(--primary); }

/* ---------- P2P market ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.segmented a, .segmented label { padding: 8px 18px; border-radius: 9px; color: var(--muted); font-weight: 600; cursor: pointer; }
.segmented a:hover { text-decoration: none; }
.segmented a.active, .segmented label.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented a.active.buy { color: var(--success); }
.segmented a.active.sell { color: var(--danger); }
.segmented.small label { padding: 6px 12px; font-size: .9rem; }
.segmented input[type=radio] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ad-list { display: grid; gap: 12px; }
.ad-card {
  display: grid; grid-template-columns: 1.3fr .8fr 1.6fr auto; gap: 12px 18px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.ad-trader strong { display: block; }
.trader-stats { color: var(--muted); font-size: .85rem; }
.ad-price { font-size: 1.35rem; font-weight: 800; }
.ad-price small { font-size: .85rem; font-weight: 600; color: var(--muted); }
.ad-price.big { font-size: 2rem; }
.ad-meta { font-size: .88rem; color: var(--muted); display: grid; gap: 2px; }
.ad-meta .methods { margin-top: 4px; }
.ad-action { text-align: end; }
@media (max-width: 760px) {
  .ad-card { grid-template-columns: 1fr auto; }
  .ad-meta { grid-column: 1 / -1; }
  .ad-action { grid-column: 1 / -1; }
  .ad-action .btn { width: 100%; }
}
.pre-wrap { white-space: pre-wrap; word-break: break-word; }
.order-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .order-layout { grid-template-columns: 1fr; } }
.order-amounts { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.order-amounts small { display: block; color: var(--muted); }
.order-amounts strong { font-size: 1.3rem; }
.order-amounts .arrow { color: var(--muted); font-size: 1.4rem; }
.card.highlight { border: 2px solid var(--primary); }
.card.highlight-danger { border: 2px solid var(--danger); }
.pay-details dd { font-size: 1.02rem; }
.countdown.urgent { color: var(--danger); }
.chat { display: flex; flex-direction: column; }
.chat-log { display: flex; flex-direction: column; gap: 8px; max-height: 460px; min-height: 180px; overflow-y: auto; padding: 8px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.chat-log.tall { max-height: 640px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); word-break: break-word; }
.msg-mine { align-self: flex-start; background: var(--primary-soft); border-color: transparent; }
.msg-theirs { align-self: flex-end; }
.msg-system { align-self: center; max-width: 95%; background: transparent; border: 0; color: var(--muted); font-size: .85rem; text-align: center; padding: 4px; }
.msg-admin { align-self: center; max-width: 95%; background: var(--warning-soft); border-color: transparent; }
.msg-who { font-size: .78rem; font-weight: 700; color: var(--warning); }
.msg-text { white-space: pre-wrap; }
.msg-at { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.chat-img { display: block; max-width: 220px; max-height: 220px; border-radius: 10px; margin-top: 6px; border: 1px solid var(--border); }
.chat-form { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.chat-form input[type=text] { flex: 1; min-width: 0; }
.chat-form .attach { cursor: pointer; }
.proof-img { max-width: 100%; max-height: 640px; border-radius: 10px; border: 1px solid var(--border); display: block; }
.compare { font-size: 1.1rem; }
.card-list { background: var(--surface); }
.order-row { color: var(--text); gap: 8px; }
.order-row:hover { text-decoration: none; }
