/* =========================================================================
   BirrX — mobile-first stylesheet
   Aesthetic: deep warm-black canvas, Ethiopian-gold accent, editorial serif
   wordmark, refined fintech tone. Built phone-first; widens gracefully.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@300;400;500;600;700&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500&family=Noto+Sans+Ethiopic:wght@400;500;600&display=swap');

:root {
  /* color */
  --bg:           #0E0C0B;
  --bg-2:        #141113;
  --surface:     #19171A;
  --surface-2:   #221F22;
  --surface-hi:  #2A262A;
  --border:      #2E2A2C;
  --border-hi:   #3D383B;
  --text:        #F5F1EA;
  --text-dim:    #94898B;
  --text-faint:  #5C5256;

  --gold:        #F5B544;
  --gold-soft:   #FFCB6B;
  --gold-deep:   #C99230;
  --gold-tint:   rgba(245, 181, 68, 0.10);

  --buy:         #4ADE80;
  --buy-tint:    rgba(74, 222, 128, 0.10);
  --sell:        #F87171;
  --sell-tint:   rgba(248, 113, 113, 0.10);
  --info:        #60A5FA;
  --warn:        #FBBF24;

  /* fonts */
  --font-ui:      'Hanken Grotesk', system-ui, sans-serif;
  --font-display: 'Instrument Serif', 'Georgia', serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;
  --font-eth:     'Noto Sans Ethiopic', 'Hanken Grotesk', sans-serif;

  /* layout */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --tap: 44px;

  --col-max: 480px;
  --nav-h:   68px;
  --hdr-h:   56px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 8px 24px rgba(0,0,0,.45);
  --shadow-gold: 0 6px 24px rgba(245,181,68,.25);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overscroll-behavior-y: none;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-soft); }

img { max-width: 100%; display: block; }

/* ---------- Shell: phone-sized column, centered on desktop ---------- */
.shell {
  max-width: var(--col-max);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
}

/* Decorative side rails on wide screens, so the phone column doesn't feel lonely */
@media (min-width: 900px) {
  body::before, body::after {
    content: "";
    position: fixed; top: 0; bottom: 0; width: calc((100vw - var(--col-max)) / 2);
    pointer-events: none; z-index: 0;
    background:
      radial-gradient(600px 400px at 50% 30%, rgba(245,181,68,.05), transparent 70%),
      linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  }
  body::before { left: 0;  border-right: 1px solid var(--border); }
  body::after  { right: 0; border-left:  1px solid var(--border); }
  .shell { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: var(--hdr-h);
  padding: 0 16px;
  background: rgba(14,12,11,.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.app-header .back-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 50%;
  color: var(--text); cursor: pointer;
}
.app-header .back-btn:hover { background: var(--surface-2); }
.app-header h1 {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  flex: 1;
}
.app-header .header-action {
  width: 36px; height: 36px; display: grid; place-items: center;
  color: var(--text-dim); cursor: pointer;
}

/* ---------- Wordmark ---------- */
.wordmark {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text);
}
.wordmark .x {
  color: var(--gold);
  font-style: normal;
  font-family: var(--font-ui);
  font-weight: 700;
  letter-spacing: -0.05em;
}

/* ---------- Layout helpers ---------- */
.page { padding: 16px; }
.section { margin-bottom: 24px; }
.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin: 0 0 10px 4px;
  font-weight: 600;
}
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt-1 { margin-top: 8px; }  .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
}
.card.flat { background: transparent; border-color: var(--border); }
.card-hero {
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(245,181,68,.18), transparent 60%),
    linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px solid var(--border-hi);
}

/* ---------- Pills / chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
}
.chip.buy   { background: var(--buy-tint);  color: var(--buy);  border-color: rgba(74,222,128,.3); }
.chip.sell  { background: var(--sell-tint); color: var(--sell); border-color: rgba(248,113,113,.3); }
.chip.gold  { background: var(--gold-tint); color: var(--gold); border-color: rgba(245,181,68,.3); }
.chip.warn  { background: rgba(251,191,36,.10); color: var(--warn); border-color: rgba(251,191,36,.3); }
.chip.info  { background: rgba(96,165,250,.10); color: var(--info); border-color: rgba(96,165,250,.3); }

/* ---------- Buttons ---------- */
.btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  padding: 12px 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn:hover  { background: var(--surface-hi); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }

.btn-primary { background: var(--gold); color: #1a1410; border-color: var(--gold-deep); box-shadow: var(--shadow-gold); }
.btn-primary:hover { background: var(--gold-soft); color: #1a1410; }

.btn-buy  { background: var(--buy);  color: #06160C; border-color: transparent; }
.btn-sell { background: var(--sell); color: #1a0606; border-color: transparent; }

.btn-ghost   { background: transparent; }
.btn-danger  { background: var(--sell-tint); color: var(--sell); border-color: rgba(248,113,113,.3); }
.btn-success { background: var(--buy-tint);  color: var(--buy);  border-color: rgba(74,222,128,.3); }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-dim);
  margin-bottom: 6px; letter-spacing: 0.02em; text-transform: uppercase;
}
.input, .select, .textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  padding: 14px 14px;
  font: inherit;
  min-height: var(--tap);
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--gold);
  background: var(--surface-2);
}
.input::placeholder { color: var(--text-faint); }
.textarea { min-height: 96px; resize: vertical; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23F5B544' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 38px;
}

/* Amount input with currency suffix */
.amount-input {
  position: relative;
}
.amount-input input {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  padding-right: 64px;
}
.amount-input .suffix {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 13px; color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--col-max);
  z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(14,12,11,.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--text-faint); text-decoration: none;
  padding: 6px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: var(--r-sm);
  position: relative;
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.active { color: var(--gold); }
.bottom-nav a.active::before {
  content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; background: var(--gold); border-radius: 0 0 4px 4px;
}
.bottom-nav .nav-center {
  background: var(--gold);
  color: #1a1410 !important;
  border-radius: 50%;
  width: 52px; height: 52px;
  align-self: center; justify-self: center;
  margin-top: -16px;
  box-shadow: var(--shadow-gold);
}
.bottom-nav .nav-center svg { width: 26px; height: 26px; }
.bottom-nav .nav-center::before { display: none; }

/* ---------- Hero balance ---------- */
.balance-hero {
  padding: 22px;
  border-radius: var(--r-xl);
}
.balance-hero .label {
  font-size: 12px; color: var(--text-dim); letter-spacing: 0.06em;
  text-transform: uppercase; margin-bottom: 6px;
}
.balance-hero .amount {
  font-family: var(--font-mono);
  font-size: 38px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
}
.balance-hero .amount .cur {
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 500;
  color: var(--gold);
  margin-left: 6px;
  letter-spacing: 0;
}
.balance-hero .sub {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------- Ad row (market list) ---------- */
.ad-row {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: border-color .15s ease, background .15s ease;
  color: var(--text);
}
.ad-row:hover { border-color: var(--border-hi); background: var(--surface-2); }
.ad-row .head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
}
.ad-row .maker {
  display: flex; align-items: center; gap: 10px;
}
.ad-row .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-deep), var(--gold));
  display: grid; place-items: center;
  color: #1a1410; font-weight: 700; font-size: 13px;
  font-family: var(--font-ui);
}
.ad-row .maker .name { font-weight: 600; font-size: 14px; }
.ad-row .maker .stats { font-size: 11px; color: var(--text-faint); }
.ad-row .rate {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--gold);
}
.ad-row .rate .cur { font-family: var(--font-ui); font-size: 11px; color: var(--text-dim); margin-left: 4px; }
.ad-row .meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-dim);
}
.ad-row .meta .methods { display: flex; flex-wrap: wrap; gap: 6px; }
.ad-row .meta .methods .m {
  font-size: 10px; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-hi); color: var(--text);
  border: 1px solid var(--border-hi);
}
.ad-row .limits {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  gap: 4px;
  position: sticky; top: var(--hdr-h); z-index: 20;
  background: var(--bg);
  padding: 0 4px;
}
.tabs a {
  flex: 1; text-align: center; padding: 12px 8px;
  color: var(--text-dim); font-weight: 600; font-size: 14px;
  border-bottom: 2px solid transparent;
  text-decoration: none;
}
.tabs a.active { color: var(--text); border-bottom-color: var(--gold); }

/* ---------- Trade timeline (order page) ---------- */
.timeline { display: flex; gap: 0; margin: 8px 0 20px; }
.timeline .step {
  flex: 1; position: relative; text-align: center;
  font-size: 10px; color: var(--text-faint); font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.timeline .step::before {
  content: ""; display: block; width: 12px; height: 12px;
  margin: 0 auto 6px;
  border-radius: 50%; background: var(--surface-2); border: 2px solid var(--border-hi);
}
.timeline .step::after {
  content: ""; position: absolute; left: 50%; right: -50%; top: 6px;
  height: 2px; background: var(--border);
}
.timeline .step:last-child::after { display: none; }
.timeline .step.done { color: var(--gold); }
.timeline .step.done::before { background: var(--gold); border-color: var(--gold); }
.timeline .step.done::after  { background: var(--gold); }
.timeline .step.current { color: var(--text); }
.timeline .step.current::before {
  background: var(--gold); border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(245,181,68,.2);
}

/* ---------- Chat ---------- */
.chat-wrap {
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.chat-messages {
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 280px;
  max-height: 440px;
  overflow-y: auto;
}
.bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.35;
  word-break: break-word;
}
.bubble.me   { align-self: flex-end;   background: var(--gold); color: #1a1410; border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 4px; }
.bubble.sys  { align-self: center; background: transparent; color: var(--text-faint);
               font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; padding: 4px 8px; }
.bubble .ts { display: block; margin-top: 2px; font-size: 10px; opacity: 0.65; font-family: var(--font-mono); }
.chat-input {
  display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--surface);
}
.chat-input input {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 14px; color: var(--text); font: inherit;
}
.chat-input input:focus { outline: none; border-color: var(--gold); }
.chat-input button {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--gold); color: #1a1410; border: none; cursor: pointer;
  display: grid; place-items: center;
}

/* ---------- KV display ---------- */
.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-dim); font-size: 13px; }
.kv .v { color: var(--text); font-size: 14px; font-weight: 500; font-family: var(--font-mono); }
.kv .v.lg { font-size: 18px; color: var(--gold); }

/* ---------- Flash messages ---------- */
.flash {
  padding: 12px 14px; border-radius: var(--r-md); margin-bottom: 14px;
  font-size: 14px; border: 1px solid;
  display: flex; gap: 10px; align-items: flex-start;
}
.flash.success { background: var(--buy-tint);  color: var(--buy);  border-color: rgba(74,222,128,.3); }
.flash.error   { background: var(--sell-tint); color: var(--sell); border-color: rgba(248,113,113,.3); }
.flash.warn    { background: rgba(251,191,36,.10); color: var(--warn); border-color: rgba(251,191,36,.3); }
.flash.info    { background: rgba(96,165,250,.10); color: var(--info); border-color: rgba(96,165,250,.3); }

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 48px 16px;
  color: var(--text-faint);
}
.empty .icon {
  width: 64px; height: 64px; margin: 0 auto 14px;
  border-radius: 50%; background: var(--surface);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--gold);
}
.empty h3 { color: var(--text); margin: 0 0 6px; font-weight: 600; font-size: 17px; }

/* ---------- Splash / auth screens ---------- */
.splash {
  min-height: 100vh;
  background:
    radial-gradient(80% 60% at 70% 10%, rgba(245,181,68,.10), transparent 65%),
    radial-gradient(60% 40% at 20% 90%, rgba(74,222,128,.06), transparent 65%),
    var(--bg);
  padding: 40px 24px;
  display: flex; flex-direction: column; justify-content: space-between;
  max-width: var(--col-max);
  margin: 0 auto;
}
.splash .brand {
  font-family: var(--font-display); font-style: italic;
  font-size: 64px; line-height: 1;
  letter-spacing: -0.03em;
  margin: 80px 0 0;
}
.splash .brand .x {
  font-family: var(--font-ui); font-style: normal; font-weight: 700;
  color: var(--gold); letter-spacing: -0.08em;
}
.splash .tagline {
  margin-top: 18px;
  font-size: 18px; color: var(--text-dim);
  max-width: 320px; line-height: 1.4;
}
.splash .tagline .eth { font-family: var(--font-eth); }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-dim   { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }
.text-gold  { color: var(--gold); }
.text-buy   { color: var(--buy); }
.text-sell  { color: var(--sell); }
.mono       { font-family: var(--font-mono); }
.serif      { font-family: var(--font-display); font-style: italic; }
.eth        { font-family: var(--font-eth); }
.center     { text-align: center; }
.small      { font-size: 12px; }
.tiny       { font-size: 11px; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-hi); border-radius: 8px; }

/* ---------- Loading spinner ---------- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(245,181,68,.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Auth pages (login/register) ---------- */
.auth-wrap { padding: 32px 22px 22px; max-width: var(--col-max); margin: 0 auto; }
.auth-wrap .brand-sm {
  font-family: var(--font-display); font-style: italic;
  font-size: 36px; letter-spacing: -0.03em; margin: 8px 0 6px;
}
.auth-wrap .brand-sm .x { font-family: var(--font-ui); font-style: normal; font-weight: 700; color: var(--gold); }
.auth-wrap h2 { font-weight: 600; margin: 16px 0 6px; font-size: 22px; letter-spacing: -0.01em; }
.auth-wrap .sub { color: var(--text-dim); margin: 0 0 24px; }

/* ---------- Trade list rows (orders page) ---------- */
.order-row {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 10px; color: var(--text);
}
.order-row .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.order-row .ref { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); }
.order-row .amount { font-family: var(--font-mono); font-size: 16px; font-weight: 500; }
.order-row .bottom { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-dim); }

/* ---------- Admin overrides (wider on desktop) ---------- */
.admin-shell { max-width: 100%; padding: 24px; }
@media (min-width: 900px) {
  .admin-shell { max-width: 1100px; margin: 0 auto; padding: 32px; }
}
.admin-shell table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden;
}
.admin-shell th, .admin-shell td {
  padding: 12px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border);
}
.admin-shell th { background: var(--surface-2); color: var(--text-dim); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; font-size: 11px; }
.admin-shell tr:last-child td { border-bottom: none; }
