/* ============================================================
   Shared theme variables
   ============================================================ */
:root {
  --bg-gradient-1: #0a0e17;
  --bg-gradient-2: #151c2c;
  --bg-gradient-3: #0d1321;
  --text-primary: #e4e7ec;
  --text-secondary: #aabbd8;
  --text-muted: #8a9bbf;
  --panel-bg-1: rgba(22, 28, 45, 0.95);
  --panel-bg-2: rgba(17, 22, 35, 0.98);
  --panel-border: rgba(255, 255, 255, 0.15);
  --input-bg: rgba(10, 14, 23, 0.6);
  --input-border: rgba(255, 255, 255, 0.2);
  --input-text: #fff;
  --input-placeholder: #4a5568;
  --results-bg: rgba(10, 14, 23, 0.5);
  --results-border: rgba(255, 255, 255, 0.1);
  --modal-bg-1: rgba(22, 28, 45, 0.98);
  --modal-bg-2: rgba(17, 22, 35, 1);
  --modal-border: rgba(255, 255, 255, 0.2);
  --dropdown-bg: rgba(22, 28, 45, 0.98);
  --title-gradient-1: #fff;
  --title-gradient-2: #a8b3cf;
  --accent: #00d4aa;
  --accent-dark: #00a884;
  --amber: #c9a84c;
  --amber-dark: #a8893a;
  --balance-label: #c9a84c;
  --gold: #c9a84c;
  --accent-dim: rgba(0, 212, 170, 0.12);
  --accent-border: rgba(0, 212, 170, 0.3);
  --buy-color: #4dabf7;
  --sell-color: #ff6b6b;
  --danger: #ff6b6b;
  --panel-bg: rgba(22, 28, 45, 0.95);
  --nav-bg: #0d1321;
  --nav-border: rgba(0, 212, 170, 0.15);
  --nav-height: 56px;
  --mobile-nav-height: 64px;
}


/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  background: var(--bg-gradient-1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 50%, var(--bg-gradient-3) 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
}

/* ============================================================
   Dev banner
   ============================================================ */
.dev-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: #7c3aed;
  color: #fff;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 0;
  text-transform: uppercase;
  display: none;
}
.dev-banner.show { display: block; }
body:has(.dev-banner.show) .app-nav { top: 23px; }
body:has(.dev-banner.show) { padding-top: 23px; }

/* ============================================================
   Desktop navigation
   ============================================================ */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--nav-height);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 4px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  margin-right: 16px;
}

.nav-brand-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.nav-brand-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

/* Dropdown nav item */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.nav-dropdown-btn:hover,
.nav-dropdown.open .nav-dropdown-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.nav-dropdown-btn .chevron {
  font-size: 0.6rem;
  transition: transform 0.2s;
  opacity: 0.6;
}

.nav-dropdown.open .chevron {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: var(--modal-bg-1);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.nav-dropdown.open .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-right .nav-dropdown-menu {
  left: auto;
  right: 0;
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-dropdown-item:hover,
.nav-dropdown-item.active {
  background: rgba(0, 212, 170, 0.1);
  color: var(--accent);
}

.nav-dropdown-divider {
  height: 1px;
  background: var(--panel-border);
  margin: 4px 0;
}

.nav-spacer { flex: 1; }

.nav-link {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.nav-link.active { color: var(--accent); }

.nav-signout-form { margin: 0; }

.nav-signout-btn {
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 8px;
  font-size: 1.1rem;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.nav-signout-btn:hover {
  color: var(--sell-color);
  background: rgba(255, 107, 107, 0.08);
}

/* ============================================================
   Mobile bottom navigation
   ============================================================ */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--nav-bg);
  border-top: 1px solid var(--nav-border);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-container {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 0 4px;
}

.mobile-nav-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 500;
  text-decoration: none;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  min-width: 56px;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
  color: var(--accent);
}

.mobile-nav-icon {
  font-size: 1.3rem;
  line-height: 1;
}

/* Popup menu above mobile nav bar */
.mobile-popup {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--modal-bg-1);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
  min-width: 240px;
  z-index: 100;
}

.mobile-nav-slot:first-child .mobile-popup {
  left: 0;
  transform: none;
}

.mobile-nav-slot:last-child .mobile-popup {
  left: auto;
  right: 0;
  transform: none;
}

.mobile-popup.show {
  display: block;
}

.mobile-popup-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-decoration: none;
  border-radius: 8px;
  cursor: pointer;
  background: none;
  border: none;
  white-space: nowrap;
  font-family: inherit;
  width: 100%;
  transition: background 0.15s, color 0.15s;
}

.mobile-popup-item:hover,
.mobile-popup-item.active {
  background: rgba(0, 212, 170, 0.1);
  color: var(--accent);
}

.mobile-popup-divider {
  height: 1px;
  background: var(--panel-border);
  margin: 4px 0;
}

.mobile-popup-item.danger {
  color: var(--text-muted);
}

.mobile-popup-item.danger:hover {
  background: rgba(255, 107, 107, 0.1);
  color: var(--sell-color);
}

/* ============================================================
   Button system
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* Sizes */
.btn-sm  { font-size: 0.78rem; padding: 5px 12px; border-radius: 6px; }
.btn-md  { font-size: 0.85rem; padding: 7px 16px; }
.btn-lg  { font-size: 0.92rem; padding: 9px 20px; }

/* Primary — accent gradient */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
}
.btn-primary:hover { opacity: 0.88; }

/* Secondary — ghost outline */
.btn-secondary {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.28);
  color: var(--text-primary);
}

/* Danger — red gradient */
.btn-danger {
  background: linear-gradient(135deg, var(--sell-color), #c0392b);
  color: #fff;
}
.btn-danger:hover { opacity: 0.88; }

/* Ghost danger — outline that fills red on hover */
.btn-danger-ghost {
  background: none;
  border: 1px solid rgba(255,107,107,0.3);
  color: var(--sell-color);
}
.btn-danger-ghost:hover {
  background: rgba(255,107,107,0.12);
  border-color: rgba(255,107,107,0.55);
}

/* Icon-only close/delete button */
.btn-icon-x {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 5px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.btn-icon-x:hover {
  color: var(--sell-color);
  background: rgba(255,107,107,0.12);
}

/* ============================================================
   Page content wrapper
   ============================================================ */
.page-content {
  padding: 24px 20px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ============================================================
   Responsive: show mobile nav, hide desktop nav at <=768px
   ============================================================ */
@media (max-width: 768px) {
  .app-nav { display: none; }
  .mobile-nav { display: block; }
  .page-content {
    padding: 16px;
    padding-bottom: calc(var(--mobile-nav-height) + 16px + env(safe-area-inset-bottom));
  }
}

body.modal-open { overflow: hidden; }

/* Status badges */
.about-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; letter-spacing: 0.3px; }
.about-badge-yes { background: rgba(0,212,170,0.15); color: var(--accent); border: 1px solid rgba(0,212,170,0.35); }
.about-badge-no { background: rgba(255,107,107,0.12); color: #ff6b6b; border: 1px solid rgba(255,107,107,0.3); }

/* 2FA security card */
.security-card-header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.security-icon { font-size: 2rem; line-height: 1; flex-shrink: 0; margin-top: 2px; }
.security-icon-active { filter: drop-shadow(0 0 6px rgba(0,212,170,0.4)); }
.security-icon-idle { opacity: 0.4; }
.security-icon-warning { color: var(--amber, #f5a623); }
.security-section-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.security-subtitle { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }
.security-status-grid { display: flex; gap: 24px; margin-bottom: 16px; flex-wrap: wrap; }
.security-status-item { display: flex; flex-direction: column; gap: 4px; }
.security-status-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; }
.security-status-value { display: flex; align-items: center; }
.security-action-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.security-hint { font-size: 0.8rem; color: var(--text-secondary); margin: 0; }

/* 2FA modal */
.twofa-modal { display: flex; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1000; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.twofa-setup-card { position: relative; background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 16px; padding: 32px 36px; width: 100%; max-width: 460px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.twofa-close-btn { position: absolute; top: 14px; right: 14px; background: none; border: none; color: var(--text-secondary); font-size: 1.3rem; cursor: pointer; line-height: 1; padding: 4px 8px; border-radius: 6px; transition: color 0.2s, background 0.2s; }
.twofa-close-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }
.twofa-header { margin-bottom: 24px; }
.twofa-header h2 { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.twofa-header p { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }
.twofa-step { display: flex; gap: 12px; margin-bottom: 12px; font-size: 0.875rem; color: var(--text-secondary); line-height: 1.6; }
.twofa-step-num { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-dim); border: 1px solid rgba(0,212,170,0.35); color: var(--accent); font-size: 0.7rem; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-top: 2px; }
.twofa-step-body strong { color: var(--text-primary); display: block; margin-bottom: 2px; }
.twofa-qr-img { display: block; margin: 10px auto; border-radius: 8px; background: #fff; padding: 8px; }
.twofa-secret { background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 8px; padding: 10px 14px; font-family: 'JetBrains Mono', monospace; font-size: 0.88rem; color: var(--accent); text-align: center; letter-spacing: 0.1em; word-break: break-all; margin-top: 8px; cursor: pointer; transition: border-color 0.2s; }
.twofa-secret:hover { border-color: var(--accent); }
.twofa-secret small { display: block; font-family: inherit; font-size: 0.7rem; color: var(--text-muted, var(--text-secondary)); margin-top: 4px; letter-spacing: 0; }
.twofa-verify-input { width: 100%; background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 8px; color: var(--input-text, var(--text-primary)); font-family: 'JetBrains Mono', monospace; font-size: 1.4rem; text-align: center; letter-spacing: 0.25em; padding: 12px 14px; outline: none; box-sizing: border-box; margin: 16px 0 10px; transition: border-color 0.2s; }
.twofa-verify-input:focus { border-color: var(--accent); }
.twofa-verify-btn { width: 100%; justify-content: center; font-size: 1rem; padding: 13px; margin-top: 4px; }
.twofa-result { border-radius: 8px; font-size: 0.85rem; padding: 10px 14px; margin-top: 10px; }
.twofa-result-error { background: rgba(255,107,107,0.15); border: 1px solid rgba(255,107,107,0.4); color: #ff6b6b; }
.twofa-result-success { background: rgba(0,212,170,0.1); border: 1px solid rgba(0,212,170,0.4); color: var(--accent); }
