/* =====================================================================
   GoldArb — Dark Premium Fintech Theme
   ===================================================================== */

:root {
  --gold: #d4af37;
  --gold-bright: #f4d35e;
  --gold-dim: rgba(212, 175, 55, 0.15);

  --bg: #0a0e17;
  --bg-alt: #0d1220;
  --card: #121826;
  --card-alt: #171f30;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);

  --text: #f1f3f7;
  --text-dim: #a7b0c0;
  --text-muted: #6b7484;

  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.15);
  --blue: #3b82f6;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);

  --sidebar-w: 260px;
  --topbar-h: 64px;
  --bottomnav-h: 62px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 15% -10%, #131a2c 0%, var(--bg) 55%);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(212,175,55,0.3); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- Layout */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, #0c1220 0%, #0a0e17 100%);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 40;
  transition: transform .25s ease;
  scrollbar-width: thin;                              /* Firefox — thin sidebar scrollbar */
  scrollbar-color: rgba(212,175,55,0.25) transparent;  /* Firefox — thumb / track */
}
.sidebar::-webkit-scrollbar { width: 4px; }             /* Chrome/Safari/Edge — thin sidebar scrollbar */
.sidebar::-webkit-scrollbar-thumb { background: rgba(212,175,55,0.25); border-radius: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--gold-bright), #a9791f);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #1a1305; font-size: 16px;
}
.sidebar-brand .name { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.sidebar-brand .name span { color: var(--gold); }

.nav-group { padding: 10px 12px; }

.nav-section { margin: 2px 0; }
.nav-section-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: none; border: none; cursor: pointer;
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-muted); padding: 14px 10px 6px;
  font-weight: 700; font-family: inherit;
}
.nav-section-toggle:hover { color: var(--text-dim); }
.nav-section-toggle .nav-section-label {
  display: flex; align-items: center; gap: 8px;
}
.nav-section-toggle .nav-section-label i {
  font-size: 13px; opacity: .9;
}
.nav-section-toggle .chevron {
  font-size: 12px; transition: transform .18s ease; opacity: .8;
}
.nav-section.collapsed .nav-section-toggle .chevron { transform: rotate(-90deg); }
.nav-section-body {
  overflow: hidden;
  max-height: 600px;
  transition: max-height .2s ease, opacity .15s ease;
  opacity: 1;
}
.nav-section.collapsed .nav-section-body {
  max-height: 0;
  opacity: 0;
}
.nav-section-body > .nav-link:first-child { margin-top: 0; }

.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 14px; font-weight: 500;
  margin: 2px 0;
}
.nav-link i { width: 18px; text-align: center; font-size: 15px; opacity: .85; }
.nav-link:hover { background: var(--card-alt); color: var(--text); }
.nav-link.active {
  background: var(--gold-dim); color: var(--gold-bright);
  box-shadow: inset 0 0 0 1px rgba(212,175,55,0.25);
}
.nav-link.active i { opacity: 1; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 30;
}
.topbar .left { display: flex; align-items: center; gap: 14px; }
.topbar .page-title { font-size: 18px; font-weight: 700; }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.sidebar-toggle {
  display: none; background: none; border: none; color: var(--text);
  font-size: 20px; cursor: pointer;
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer; position: relative;
}
.icon-btn:hover { color: var(--gold); border-color: var(--border-strong); }
.badge-dot {
  position: absolute; top: -3px; right: -3px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--red); border: 2px solid var(--bg);
}
.avatar-chip {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 5px 10px 5px 5px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--border);
}
.avatar-chip .av {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-bright), #8a6316);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #1a1305;
}
.avatar-chip .un { font-size: 13px; font-weight: 600; }

.content { padding: 22px 24px 90px; flex: 1; }

/* ---------------------------------------------------------------- Cards */
.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-alt) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-header h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-header .muted { color: var(--text-muted); font-size: 12.5px; }

.stat-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px;
  margin-bottom: 20px;
}
@media (max-width: 1200px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 16px;
}
.stat-card .label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.stat-card .value { font-size: 20px; font-weight: 800; margin-top: 6px; letter-spacing: -.2px; }
.stat-card .delta { font-size: 12px; margin-top: 4px; font-weight: 600; }
.stat-card .delta.up { color: var(--green); }
.stat-card .delta.down { color: var(--red); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- Live gold card */
.live-gold-card {
  background: radial-gradient(600px 200px at 100% 0%, rgba(212,175,55,0.15), transparent), var(--card);
  border: 1px solid rgba(212,175,55,0.25);
  border-radius: var(--radius); padding: 22px;
}
.live-gold-card .pair { font-size: 13px; color: var(--text-dim); font-weight: 700; letter-spacing: .06em; }
.live-gold-card .price { font-size: 38px; font-weight: 800; margin: 6px 0; color: var(--gold-bright); }
.live-gold-card .chg { font-size: 14px; font-weight: 700; }
.live-gold-card .meta { display: flex; gap: 22px; margin-top: 16px; font-size: 12.5px; color: var(--text-muted); }
.live-gold-card .meta b { color: var(--text-dim); display: block; font-size: 13px; }

/* ---------------------------------------------------------------- Best opportunity */
.opp-card {
  border-radius: var(--radius); padding: 20px;
  background: linear-gradient(135deg, rgba(212,175,55,0.14), rgba(212,175,55,0.02));
  border: 1px solid rgba(212,175,55,0.3);
}
.opp-card .tag {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .08em;
  color: #1a1305; background: var(--gold-bright); padding: 4px 10px; border-radius: 999px;
  margin-bottom: 12px;
}
.opp-row { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; }
.opp-side { text-align: left; }
.opp-side .lbl { font-size: 11px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.opp-side .val { font-size: 16px; font-weight: 700; margin-top: 2px; }
.opp-arrow { color: var(--gold); font-size: 18px; }

/* ---------------------------------------------------------------- Tables */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); padding: 10px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle; white-space: nowrap;
}
table.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.table-scroll { overflow-x: auto; }

.market-cell { display: flex; align-items: center; gap: 8px; }
.market-cell .flag { font-size: 18px; }

/* ---------------------------------------------------------------- Badges / P&L */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
}
.pill.green { background: var(--green-dim); color: var(--green); }
.pill.red { background: var(--red-dim); color: var(--red); }
.pill.amber { background: var(--amber-dim); color: var(--amber); }
.pill.gray { background: rgba(255,255,255,0.06); color: var(--text-dim); }
.pill.gold { background: var(--gold-dim); color: var(--gold-bright); }

.text-up { color: var(--green); font-weight: 700; }
.text-down { color: var(--red); font-weight: 700; }

/* ---------------------------------------------------------------- Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.form-control, select.form-control {
  width: 100%; background: var(--bg-alt); border: 1px solid var(--border-strong);
  color: var(--text); padding: 11px 13px; border-radius: 10px; font-size: 14px;
  outline: none; transition: border-color .15s;
}
.form-control:focus { border-color: var(--gold); }
.input-suffix { position: relative; }
.input-suffix .suffix {
  position: absolute; right: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 13px; pointer-events: none;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; font-weight: 700; font-size: 14px;
  border: 1px solid transparent; cursor: pointer; transition: all .15s;
}
.btn-gold { background: linear-gradient(135deg, var(--gold-bright), #b3891f); color: #1a1305; }
.btn-gold:hover { filter: brightness(1.08); }
.btn-green { background: var(--green); color: #06210f; }
.btn-red { background: var(--red); color: #2a0808; }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }

.tab-bar { display: flex; gap: 6px; background: var(--bg-alt); padding: 4px; border-radius: 10px; width: fit-content; }
.tab-bar button {
  background: none; border: none; color: var(--text-dim); padding: 7px 14px;
  border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.tab-bar button.active { background: var(--gold-dim); color: var(--gold-bright); }

/* ---------------------------------------------------------------- Order summary */
.order-summary { background: var(--bg-alt); border-radius: 10px; padding: 14px 16px; }
.order-summary .row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.5px; color: var(--text-dim); }
.order-summary .row b { color: var(--text); font-weight: 700; }
.order-summary .row.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 15px; }
.order-summary .row.total b { color: var(--gold-bright); }

/* ---------------------------------------------------------------- Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4,6,10,0.7); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: var(--card); border: 1px solid var(--border-strong); border-radius: var(--radius);
  width: 100%; max-width: 440px; box-shadow: var(--shadow);
}
.modal-box .modal-header { padding: 18px 20px; border-bottom: 1px solid var(--border); font-weight: 700; }
.modal-box .modal-body { padding: 18px 20px; }
.modal-box .modal-footer { padding: 16px 20px; display: flex; gap: 10px; border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- Toasts */
.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--card); border: 1px solid var(--border-strong); border-left: 3px solid var(--gold);
  border-radius: 10px; padding: 12px 16px; font-size: 13.5px; box-shadow: var(--shadow);
  min-width: 240px; animation: toast-in .2s ease;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------------------------------------------- Skeletons / empty */
.skel { background: linear-gradient(90deg, var(--card) 25%, var(--card-alt) 50%, var(--card) 75%); background-size: 200% 100%; animation: skel 1.3s infinite; border-radius: 8px; }
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.empty-state { text-align: center; padding: 46px 20px; color: var(--text-muted); }
.empty-state i { font-size: 32px; margin-bottom: 10px; display: block; color: var(--text-muted); }

/* ---------------------------------------------------------------- Auth pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo .mark {
  width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 10px;
  background: linear-gradient(135deg, var(--gold-bright), #a9791f);
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: #1a1305; font-size: 22px;
}

/* ---------------------------------------------------------------- Mobile bottom nav */
.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottomnav-h);
  background: rgba(10,14,23,0.95); backdrop-filter: blur(10px); border-top: 1px solid var(--border);
  z-index: 45; align-items: center; justify-content: space-around;
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--text-muted); font-size: 10.5px; }
.bottom-nav a.active { color: var(--gold); }
.bottom-nav a i { font-size: 18px; }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .bottom-nav { display: flex; }
  .content { padding: 16px 14px 90px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.overlay-dim { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 39; display: none; }
.overlay-dim.show { display: block; }

.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.25);
  border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chart-wrap { position: relative; height: 320px; }
