/* ============================================================
   METAL TRACKER - COMPLETE PREMIUM THEME (v9.2)
   Production-Ready Split File CSS
   ✅ Connection Toast (Facebook-style top bar)
   ✅ PWA vs Browser differences (display-mode)
   ✅ No-internet overlay removed (replaced with toast)
   ✅ All components + utility classes included
   ============================================================ */

/* ============================================================
   1. CSS VARIABLES
   ============================================================ */
:root {
  --bg-color: #09090B;
  --surface-color: #18181B;
  --surface-light: #27272A;
  --surface-elevated: #27272A;

  --text-primary: #FAFAFA;
  --text-secondary: #A1A1AA;
  --text-tertiary: #71717A;

  --border-color: #27272A;
  --border-light: #3F3F46;
  --border-gold: rgba(212, 175, 55, 0.4);
  --border-silver: rgba(226, 232, 240, 0.4);

  --shadow: rgba(0, 0, 0, 0.5);

  --gold-primary: #FFD700;
  --gold-secondary: #FFA500;
  --gold-glow: rgba(212, 175, 55, 0.3);

  --silver-primary: #E2E8F0;
  --silver-secondary: #CBD5E1;
  --silver-glow: rgba(226, 232, 240, 0.3);

  --accent-primary: var(--gold-primary);
  --accent-secondary: var(--gold-secondary);
  --accent-glow: var(--gold-glow);
  --accent-border: var(--border-gold);

  --success: #10B981;
  --error: #EF4444;
  --alert: #F97316;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --header-height: 52px;
  --toast-offset: 0px;
}

body.silver-mode {
  --accent-primary: var(--silver-primary);
  --accent-secondary: var(--silver-secondary);
  --accent-glow: var(--silver-glow);
  --accent-border: var(--border-silver);
}

body.light-theme {
  --bg-color: #FAF9F6;
  --surface-color: #FFFFFF;
  --surface-light: #F0EDE6;
  --surface-elevated: #FFFFFF;

  --text-primary: #18181B;
  --text-secondary: #52525B;
  --text-tertiary: #71717A;

  --border-color: #E5E2D9;
  --border-light: #D4D0C5;
  --border-gold: rgba(184, 134, 11, 0.35);
  --border-silver: rgba(112, 128, 144, 0.35);

  --shadow: rgba(0, 0, 0, 0.08);

  --gold-primary: #D4AF37;
  --gold-secondary: #F5D061;
  --gold-glow: rgba(184, 134, 11, 0.25);

  --silver-primary: #708090;
  --silver-secondary: #A9A9A9;
  --silver-glow: rgba(112, 128, 144, 0.2);

  --success: #059669;
  --error: #DC2626;
  --alert: #EA580C;
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  padding-bottom: calc(80px + var(--safe-bottom));
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

@media (min-width: 1024px) {
  body { padding-bottom: 0; font-size: 15px; }
}

body.loading-active,
body.sidebar-open { overflow: hidden; }

img, svg { max-width: 100%; height: auto; display: block; }

/* ============================================================
   3. UTILITY CLASSES
   ============================================================ */
.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }
.hidden { display: none !important; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.contents { display: contents; }

.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.flex-1 { flex: 1 1 0%; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-grow { flex-grow: 1; }

.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.justify-around { justify-content: space-around; }

.self-center { align-self: center; }

.gap-0-5 { gap: 2px; }
.gap-1 { gap: 4px; }
.gap-1-5 { gap: 6px; }
.gap-2 { gap: 8px; }
.gap-2-5 { gap: 10px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-x-3 { column-gap: 12px; }
.gap-y-1 { row-gap: 4px; }
.gap-x-1-5 { column-gap: 6px; }
.gap-y-0-5 { row-gap: 2px; }

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.space-y-0-5 > * + * { margin-top: 2px; }
.space-y-1 > * + * { margin-top: 4px; }
.space-y-1-5 > * + * { margin-top: 6px; }
.space-y-2 > * + * { margin-top: 8px; }
.space-y-3 > * + * { margin-top: 12px; }
.space-y-4 > * + * { margin-top: 16px; }

.w-full { width: 100%; }
.h-full { height: 100%; }
.w-auto { width: auto; }
.min-w-0 { min-width: 0; }
.max-w-2xl { max-width: 42rem; }
.max-w-7xl { max-width: 80rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.w-2-5 { width: 10px; }
.h-2-5 { height: 10px; }
.w-3 { width: 12px; }
.h-3 { height: 12px; }
.w-3-5 { width: 14px; }
.h-3-5 { height: 14px; }
.w-4 { width: 16px; }
.h-4 { height: 16px; }
.w-5 { width: 20px; }
.h-5 { height: 20px; }
.w-6 { width: 24px; }
.h-6 { height: 24px; }
.h-1-5 { height: 6px; }

.mb-0-5 { margin-bottom: 2px; }
.mb-1 { margin-bottom: 4px; }
.mb-1-5 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

.mt-0-5 { margin-top: 2px; }
.mt-1 { margin-top: 4px; }
.mt-1-5 { margin-top: 6px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }

.ml-1 { margin-left: 4px; }
.mr-0-5 { margin-right: 2px; }
.mr-1 { margin-right: 4px; }
.-mt-5 { margin-top: -20px; }

.p-0-5 { padding: 2px; }
.p-1 { padding: 4px; }
.p-1-5 { padding: 6px; }
.p-2 { padding: 8px; }
.p-2-5 { padding: 10px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }

.px-1 { padding-left: 4px; padding-right: 4px; }
.px-1-5 { padding-left: 6px; padding-right: 6px; }
.px-2 { padding-left: 8px; padding-right: 8px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }

.py-0-5 { padding-top: 2px; padding-bottom: 2px; }
.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-1-5 { padding-top: 6px; padding-bottom: 6px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }

.pl-1 { padding-left: 4px; }
.pl-2 { padding-left: 8px; }
.pr-1 { padding-right: 4px; }
.pr-2 { padding-right: 8px; }
.pt-1 { padding-top: 4px; }
.pt-2 { padding-top: 8px; }
.pt-3 { padding-top: 12px; }
.pb-2 { padding-bottom: 8px; }
.pb-20 { padding-bottom: 80px; }
.pt-14 { padding-top: 56px; }

.text-9 { font-size: 9px; line-height: 1.3; }
.text-10 { font-size: 10px; line-height: 1.4; }
.text-11 { font-size: 11px; line-height: 1.4; }
.text-\[9px\] { font-size: 9px; line-height: 1.3; }
.text-\[10px\] { font-size: 10px; line-height: 1.4; }
.text-\[11px\] { font-size: 11px; line-height: 1.4; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }

.italic { font-style: italic; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.uppercase { text-transform: uppercase; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.whitespace-nowrap { white-space: nowrap; }
.tabular-nums { font-variant-numeric: tabular-nums !important; }
.leading-tight { line-height: 1.25; }

.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-tertiary { color: var(--text-tertiary) !important; }
.text-success { color: var(--success) !important; }
.text-error { color: var(--error) !important; }
.text-alert { color: var(--alert) !important; }
.text-gold { color: var(--gold-primary) !important; }
.text-silver { color: var(--silver-primary) !important; }
.text-white { color: #FFFFFF; }
.text-black { color: #000000; }

.rounded { border-radius: 4px; }
.rounded-md { border-radius: 6px; }
.rounded-lg { border-radius: 8px; }
.rounded-xl { border-radius: 12px; }
.rounded-2xl { border-radius: 16px; }
.rounded-full { border-radius: 9999px; }

.border { border-width: 1px; border-style: solid; border-color: var(--border-color); }
.border-0 { border: none; }
.border-2 { border-width: 2px; border-style: solid; }
.border-4 { border-width: 4px; border-style: solid; }
.border-t { border-top-width: 1px; border-top-style: solid; border-top-color: var(--border-color); }
.border-b { border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: var(--border-color); }
.border-l { border-left-width: 1px; border-left-style: solid; border-left-color: var(--border-color); }

.overflow-hidden { overflow: hidden; }
.overflow-x-auto { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.overflow-y-auto { overflow-y: auto; }

.relative { position: relative; }
.fixed { position: fixed; }
.absolute { position: absolute; }
.sticky { position: sticky; }
.top-0 { top: 0; }
.left-0 { left: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }

.z-10 { z-index: 10; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.pointer-events-none { pointer-events: none; }

.transition-all { transition: all 0.2s; }
.transition { transition: all 0.15s; }

.opacity-0 { opacity: 0; }
.opacity-25 { opacity: 0.25; }
.opacity-50 { opacity: 0.5; }
.opacity-70 { opacity: 0.7; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

.hover\:opacity-70:hover { opacity: 0.7; }
.hover\:opacity-100:hover { opacity: 1; }

.shadow-sm { box-shadow: 0 1px 2px var(--shadow); }
.shadow { box-shadow: 0 2px 4px var(--shadow); }
.shadow-lg { box-shadow: 0 8px 16px var(--shadow); }
.shadow-xl { box-shadow: 0 12px 24px var(--shadow); }

.animate-spin { animation: spin 1s linear infinite; }

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

@keyframes pulseIcon {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.75; }
}

@keyframes spinRing {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUpFade {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   4. APP HEADER
   ============================================================ */
.app-header {
  position: fixed;
  top: var(--toast-offset);
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  padding-top: calc(8px + var(--safe-top));
  background-color: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  min-height: var(--header-height);
  transition: top 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent-primary);
  flex: 1;
  min-width: 0;
  margin: 0;
  letter-spacing: 0.3px;
  transition: color 0.3s ease;
}

@media (min-width: 1024px) {
  .header-title { font-size: 1.05rem; }
}


.header-title > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.hide-mobile { display: inline; }
.hide-tablet { display: inline; }

@media (max-width: 639px) {
  .hide-mobile { display: none !important; }
}

@media (max-width: 1023px) {
  .hide-tablet { display: none !important; }
}

.hamburger-btn {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 11px 8px;
  z-index: 60;
  margin-right: 4px;
  flex-shrink: 0;
}

.hamburger-line {
  width: 100%;
  height: 2.5px;
  background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  border-radius: 2px;
  transition: all 0.3s ease;
  box-shadow: 0 0 4px var(--accent-glow);
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
  transform: translateY(8.75px) rotate(45deg);
}
.hamburger-btn.active .hamburger-line:nth-child(2) { opacity: 0; }
.hamburger-btn.active .hamburger-line:nth-child(3) {
  transform: translateY(-8.75px) rotate(-45deg);
}

.icon-btn {
  background: transparent;
  border: none;
  padding: 6px;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: opacity 0.2s, background-color 0.2s;
  flex-shrink: 0;
}

.icon-btn:hover { opacity: 0.7; }
.icon-btn:active { transform: scale(0.95); }

.settings-btn { color: var(--text-primary); }

.user-profile {
  display: none;
  align-items: center;
  gap: 6px;
}

.user-profile.flex { display: flex; }

.user-photo {
  height: 24px;
  width: 24px;
  border-radius: 9999px;
  border: 2px solid var(--accent-primary);
  object-fit: cover;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

/* ============================================================
   5. MAIN CONTENT
   ============================================================ */
.app-main {
  padding-top: calc(60px + var(--toast-offset));
  padding-left: 8px;
  padding-right: 8px;
  padding-bottom: calc(80px + var(--safe-bottom));
  max-width: 80rem;
  margin: 0 auto;
  min-height: 100vh;
  transition: padding-top 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 1024px) {
  .app-main {
    padding-top: calc(68px + var(--toast-offset));
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 24px;
  }
}

/* ============================================================
   6. CARDS
   ============================================================ */
.card {
  background-color: var(--surface-color);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 2px 8px var(--shadow);
  border: 1px solid var(--border-color);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 768px) {
  .card { padding: 16px; border-radius: 18px; }
}

.card:hover {
  border-color: var(--border-light);
  box-shadow: 0 4px 12px var(--shadow);
}

.card-compact {
  background-color: var(--surface-light);
  border-radius: 12px;
  padding: 10px;
  border: 1px solid var(--border-color);
}

.live-card {
  background: linear-gradient(135deg, var(--surface-color) 0%, #1A1608 100%);
  border: 1px solid var(--accent-border);
  box-shadow: 0 4px 16px var(--shadow), 0 0 20px var(--accent-glow);
  transition: all 0.3s ease;
}

body.light-theme .live-card {
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  border: 1px solid var(--accent-border);
  box-shadow: 0 4px 16px var(--shadow), 0 0 20px var(--accent-glow);
}

body.silver-mode .live-card {
  background: linear-gradient(135deg, var(--surface-color) 0%, #1A1A1E 100%) !important;
}
body.light-theme.silver-mode .live-card {
  background: linear-gradient(135deg, #F8FAFC 0%, #E2E8F0 100%) !important;
}

.live-card.silver-mode {
  background: linear-gradient(135deg, var(--surface-color) 0%, #1A1A1E 100%) !important;
  border: 1px solid var(--border-silver) !important;
  box-shadow: 0 4px 16px var(--shadow), 0 0 20px var(--silver-glow) !important;
}

body.light-theme .live-card.silver-mode {
  background: linear-gradient(135deg, #F8FAFC 0%, #E2E8F0 100%) !important;
  border: 1px solid var(--border-silver) !important;
  box-shadow: 0 4px 16px var(--shadow), 0 0 20px var(--silver-glow) !important;
}

/* ============================================================
   7. TRACKER HEADER
   ============================================================ */
.tracker-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

@media (min-width: 1024px) {
  .tracker-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
}

.tracker-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: nowrap;
  overflow: hidden;
  min-width: 0;
}

@media (min-width: 1024px) {
  .tracker-title-row {
    justify-content: flex-start;
    gap: 10px;
  }
}

.tracker-title-text {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  min-width: 0;
}

@media (min-width: 1024px) {
  .tracker-title-text { font-size: 1rem; }
}

.tracker-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  flex-wrap: nowrap;
  min-width: 0;
}

.tracker-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.metal-toggle {
  flex-shrink: 0;
}

.source-select {
  flex: 1;
  min-width: 0;
  text-overflow: ellipsis;
}

.refresh-btn {
  flex-shrink: 0;
}

@media (max-width: 1023px) {
  .tracker-controls { gap: 5px; }

  .metal-toggle {
    padding: 2px;
    gap: 2px;
    flex-shrink: 0;
  }
  .metal-btn {
    padding: 5px 8px;
    font-size: 0.64rem;
    min-height: 30px;
    letter-spacing: 0;
  }

  .tracker-actions {
    gap: 5px;
    flex: 1;
    min-width: 0;
  }

  .source-select {
    padding: 6px 22px 6px 8px;
    font-size: 0.7rem;
    min-height: 32px;
    background-size: 11px;
    background-position: right 6px center;
    flex: 1;
    min-width: 0;
  }

  .refresh-btn {
    padding: 6px 10px !important;
    font-size: 0.7rem !important;
    min-height: 32px !important;
    gap: 4px !important;
    flex-shrink: 0;
  }
  .refresh-btn svg {
    width: 12px;
    height: 12px;
  }
}

@media (min-width: 1024px) {
  .tracker-controls {
    width: auto;
    justify-content: flex-end;
    gap: 8px;
  }
  .tracker-actions {
    flex: 0 0 auto;
  }
}

.metal-toggle {
  display: flex;
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
  background-color: var(--surface-light);
  border: 1px solid var(--border-color);
}

.metal-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  min-height: 32px;
  white-space: nowrap;
}

.metal-btn:hover { color: var(--text-primary); }

#toggle-gold.active {
  background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-secondary) 100%);
  color: #000000;
  box-shadow: 0 2px 6px var(--gold-glow);
}

#toggle-silver.active {
  background: linear-gradient(135deg, var(--silver-primary) 0%, var(--silver-secondary) 100%);
  color: #000000;
  box-shadow: 0 2px 6px var(--silver-glow);
}

.metal-btn.active {
  color: #000000;
}

.source-select {
  background-color: var(--surface-light);
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  padding: 6px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  outline: none;
  min-height: 34px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.source-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.refresh-btn {
  padding: 6px 10px !important;
  font-size: 0.72rem !important;
  min-height: 34px !important;
  gap: 4px;
}

/* ============================================================
   8. RATE CARDS
   ============================================================ */
.rate-card {
  background: linear-gradient(135deg, var(--surface-light) 0%, var(--surface-color) 100%);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 12px;
  transition: all 0.3s;
}

@media (min-width: 768px) {
  .rate-card { padding: 14px; border-radius: 16px; }
}

.rate-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--shadow), 0 0 12px var(--accent-glow);
}

.rate-card.highlight {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.15) 0%, rgba(245, 208, 97, 0.05) 100%);
  border: 1px solid var(--accent-border);
  box-shadow: 0 0 16px var(--accent-glow);
}

body.light-theme .rate-card.highlight {
  background: linear-gradient(135deg, rgba(184, 134, 11, 0.12) 0%, rgba(218, 165, 32, 0.04) 100%);
}

body.silver-mode .rate-card.highlight {
  background: linear-gradient(135deg, rgba(226,232,240,0.15) 0%, rgba(203,213,225,0.05) 100%);
}
body.light-theme.silver-mode .rate-card.highlight {
  background: linear-gradient(135deg, rgba(112,128,144,0.12) 0%, rgba(169,169,169,0.04) 100%);
}

.rate-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 0;
  flex-wrap: nowrap;
  margin: 0;
  overflow: hidden;
}

.rate-card-title .truncate {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rate-card-title .flex-shrink-0,
.rate-card-title > span:first-child {
  flex-shrink: 0;
}

.rate-card-title .last-update-text {
  flex-shrink: 0;
  white-space: nowrap;
  margin-left: auto;
}

@media (max-width: 1023px) {
  .rate-card-title {
    flex-wrap: wrap;
    row-gap: 2px;
  }
  .rate-card-title .last-update-text {
    flex-basis: 100%;
    margin-left: 0;
    margin-top: 2px;
    text-align: left;
    opacity: 0.85;
  }
}

/* ============================================================
   9. CURRENCY BADGES
   ============================================================ */
.currency-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  white-space: nowrap;
}

.badge-usd {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-pkr {
  background: var(--accent-glow);
  color: var(--accent-primary);
  border: 1px solid var(--accent-border);
}

/* ============================================================
   10. SPOT DISPLAY
   ============================================================ */
.spot-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  gap: 8px;
}

.spot-usd {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.03) 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.spot-pkr {
  background: linear-gradient(135deg, var(--accent-glow) 0%, rgba(212, 175, 55, 0.03) 100%);
  border: 1px solid var(--accent-border);
}

.spot-value {
  color: var(--success);
  font-weight: 800;
  font-size: 1.15rem;
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.spot-value.pkr-spot {
  color: var(--accent-primary);
  text-shadow: 0 0 10px var(--accent-glow);
}

.spot-value.na-value {
  color: var(--text-tertiary);
  font-size: 0.95rem;
  text-shadow: none;
  font-style: italic;
}

@media (min-width: 768px) {
  .spot-value { font-size: 1.35rem; }
}

/* ============================================================
   11. TABLES
   ============================================================ */
table {
  font-size: 0.8rem;
  border-collapse: collapse;
  width: 100%;
}

.rate-table {
  width: 100%;
  text-align: left;
  border-collapse: collapse;
}

.rate-table th,
.rate-table td { padding: 8px 6px; }

@media (min-width: 768px) {
  table { font-size: 0.85rem; }
  table th, table td { padding: 10px 8px; }
}

/* ============================================================
   12. OHLC
   ============================================================ */
.ohlc-horizontal {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: nowrap;
}

.ohlc-item {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.ohlc-item p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  line-height: 1.4;
}

.ohlc-item.high {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(16, 185, 129, 0.08) 100%);
  border-color: rgba(16, 185, 129, 0.6);
  box-shadow: inset 0 0 12px rgba(16, 185, 129, 0.15), 0 0 8px rgba(16, 185, 129, 0.2);
}
.ohlc-item.high p:last-child {
  color: var(--success) !important;
  opacity: 1;
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
  font-weight: 800;
}

.ohlc-item.low {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.25) 0%, rgba(239, 68, 68, 0.08) 100%);
  border-color: rgba(239, 68, 68, 0.6);
  box-shadow: inset 0 0 12px rgba(239, 68, 68, 0.15), 0 0 8px rgba(239, 68, 68, 0.2);
}
.ohlc-item.low p:last-child {
  color: var(--error) !important;
  opacity: 1;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
  font-weight: 800;
}

/* ============================================================
   13. TABS & TOGGLES
   ============================================================ */
.tab-container {
  display: flex;
  background-color: var(--surface-light);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.3s;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: transparent;
  min-height: 40px;
  font-family: inherit;
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: #000000;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.toggle-btn {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border-color);
  cursor: pointer;
  font-weight: 700;
  transition: all 0.3s;
  font-size: 0.8rem;
  min-height: 42px;
  font-family: inherit;
  background: transparent;
  color: var(--text-secondary);
}

.toggle-btn.active-pkr,
.toggle-btn.active-usd {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: #000000;
  border-color: var(--accent-primary);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.toggle-btn.inactive {
  background-color: var(--surface-light);
  color: var(--text-secondary);
}

.toggle-btn.active-drops {
  background: linear-gradient(135deg, #DC2626 0%, #991B1B 100%);
  color: #FFF;
  border-color: #DC2626;
}

.toggle-btn.active-rises {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #FFF;
  border-color: #059669;
}

/* ============================================================
   14. INPUTS & BUTTONS
   ============================================================ */
.input, .select {
  background-color: var(--surface-light);
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: all 0.2s;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
}

.input:focus, .select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background-color: var(--surface-elevated);
}

select.select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23A1A1AA'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 36px;
}

textarea.input { resize: vertical; min-height: 60px; font-family: inherit; }

.btn {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: #000000;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.85rem;
  box-shadow: 0 2px 8px var(--accent-glow);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--accent-glow);
}

.btn:active { transform: scale(0.97); }

.btn:disabled {
  background: var(--surface-light);
  color: var(--text-tertiary);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.75rem;
  border-radius: 10px;
  min-height: 38px;
}

.btn-secondary {
  background: transparent;
  border: 1.5px solid var(--accent-primary);
  color: var(--accent-primary);
  box-shadow: none;
}

.btn-secondary:hover {
  background: var(--accent-glow);
  box-shadow: 0 0 12px var(--accent-glow);
}

.btn-danger {
  background: linear-gradient(135deg, #DC2626 0%, #991B1B 100%);
  color: #FFF;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

/* ============================================================
   15. NAVIGATION
   ============================================================ */
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 12px;
  color: var(--text-secondary);
  transition: all 0.2s;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
  gap: 4px;
  min-height: 48px;
  min-width: 48px;
}

.nav-item.active {
  color: var(--accent-primary);
  background-color: var(--accent-glow);
  box-shadow: 0 0 12px var(--accent-glow);
}

.nav-item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--surface-color);
  border-top: 1px solid var(--border-color);
  justify-content: space-around;
  padding: 8px 0;
  padding-bottom: calc(8px + var(--safe-bottom));
  z-index: 50;
  box-shadow: 0 -4px 16px var(--shadow);
}

@media (min-width: 1024px) {
  .bottom-nav { display: none; }
}

.sidebar-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(9, 9, 11, 0.75);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.sidebar {
  position: fixed;
  left: -280px;
  top: 0; bottom: 0;
  width: 270px;
  background-color: var(--surface-color);
  border-right: 1px solid var(--border-color);
  padding: 18px 14px;
  padding-top: calc(18px + var(--safe-top) + var(--toast-offset));
  padding-bottom: calc(18px + var(--safe-bottom));
  z-index: 50;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding-top 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  box-shadow: 4px 0 20px var(--shadow);
}

.sidebar.active { left: 0; }

.sidebar .nav-item {
  flex-direction: row;
  padding: 14px 18px;
  font-size: 0.95rem;
  gap: 14px;
  justify-content: flex-start;
  margin-bottom: 6px;
  min-height: 50px;
}

.sidebar .nav-item:hover {
  background-color: var(--accent-glow);
  border-left: 3px solid var(--accent-primary);
  padding-left: 15px;
}

/* ============================================================
   16. TOASTS & OVERLAYS
   ============================================================ */
.toast {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: var(--surface-elevated);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 12px;
  box-shadow: 0 8px 24px var(--shadow);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 90%;
  border: 1px solid var(--border-light);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }
.toast.alert { border-left: 4px solid var(--alert); }

/* ============================================================
   16b. CONNECTION TOAST (Facebook-style top bar)
   ============================================================ */
.connection-toast {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  padding-top: calc(10px + var(--safe-top));
  background: linear-gradient(135deg, #DC2626 0%, #991B1B 100%);
  color: #FFFFFF;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  transform: translateY(-100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.connection-toast.show {
  transform: translateY(0);
}

.connection-toast.online {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.connection-toast-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.connection-toast.online .connection-toast-icon {
  display: none;
}

/* Loading overlay - only for first load */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(9, 9, 11, 0.92);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.loading-overlay.show {
  display: flex;
  opacity: 1;
  pointer-events: all;
}

.loading-content {
  text-align: center;
  padding: 24px 32px;
  background: linear-gradient(135deg, var(--surface-color) 0%, #1A1608 100%);
  border: 1.5px solid var(--accent-border);
  border-radius: 20px;
  box-shadow: 0 12px 48px var(--shadow), 0 0 32px var(--accent-glow);
  min-width: 220px;
  max-width: 280px;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

body.light-theme .loading-content {
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
}

body.silver-mode .loading-content {
  background: linear-gradient(135deg, var(--surface-color) 0%, #1A1A1E 100%);
}
body.light-theme.silver-mode .loading-content {
  background: linear-gradient(135deg, #F8FAFC 0%, #E2E8F0 100%);
}

.loading-overlay.show .loading-content {
  transform: scale(1);
  animation: slideUpFade 0.4s ease;
}

.loading-spinner {
  position: relative;
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-ring {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border: 3px solid transparent;
  border-top-color: var(--accent-primary);
  border-right-color: var(--accent-secondary);
  border-radius: 50%;
  animation: spinRing 1s linear infinite;
  box-shadow: 0 0 16px var(--accent-glow);
}

.loading-icon {
  width: 28px;
  height: 28px;
  color: var(--accent-primary);
  animation: pulseIcon 1.5s ease-in-out infinite;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.loading-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent-primary);
  margin: 0 0 6px 0;
  text-shadow: 0 0 12px var(--accent-glow);
}

.loading-subtitle {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin: 0;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
}



/* ============================================================
   18. LIVE BADGE / EXCHANGE BADGE
   ============================================================ */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(16, 185, 129, 0.1) 100%);
  color: var(--success);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 1px;
  border: 1px solid rgba(16, 185, 129, 0.4);
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.2);
}

.live-dot {
  width: 7px;
  height: 7px;
  background-color: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
  box-shadow: 0 0 6px var(--success);
}

.exchange-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(16, 185, 129, 0.08) 100%);
  color: var(--success);
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.15);
  white-space: nowrap;
  flex-shrink: 0;
}

.exchange-badge svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.last-update-text {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent-primary);
  white-space: nowrap;
  letter-spacing: 0.3px;
}

/* ============================================================
   19. ERROR BANNER
   ============================================================ */
.error-banner {
  padding: 12px;
  border-radius: 10px;
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid var(--error);
  color: var(--error);
  margin-bottom: 12px;
}

.error-banner-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.error-banner-content svg { flex-shrink: 0; }

/* ============================================================
   20. CALCULATOR / ZAKAT
   ============================================================ */
.auto-total-display {
  background-color: var(--bg-color);
  border: 2px dashed var(--border-light);
  border-radius: 10px;
  padding: 12px 14px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  transition: all 0.2s;
  gap: 8px;
}

.auto-total-display .total-label {
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 5px;
}

.auto-total-display .total-value {
  color: var(--accent-primary);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.3px;
  text-shadow: 0 0 8px var(--accent-glow);
}

.calc-input {
  background-color: var(--bg-color);
  border: 2px solid var(--border-light);
  border-radius: 12px;
  color: var(--text-primary);
  padding: 4px 14px;
  width: 100%;
  outline: none;
  font-size: 1.3rem;
  font-weight: 700;
  transition: all 0.2s;
  min-height: 48px;
  font-family: inherit;
}

.calc-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.karat-tab {
  padding: 6px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border-color);
  cursor: pointer;
  font-weight: 700;
  transition: all 0.3s;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: transparent;
  min-height: 38px;
  font-family: inherit;
}

.karat-tab.active {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: #000000;
  border-color: var(--accent-primary);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.unit-toggle {
  display: flex;
  background-color: var(--surface-light);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--border-color);
}

.unit-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.3s;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: transparent;
  min-height: 38px;
  font-family: inherit;
}

.unit-btn.active {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: #000000;
  box-shadow: 0 2px 6px var(--accent-glow);
}

.zakat-card {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.05) 100%);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.zakat-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.zakat-badge.reached {
  background: rgba(16, 185, 129, 0.25);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.2);
}

.zakat-badge.below {
  background: rgba(113, 113, 122, 0.2);
  color: var(--text-secondary);
  border: 1px solid rgba(113, 113, 122, 0.4);
}

/* ============================================================
   21. PROGRESS BAR
   ============================================================ */
.progress-bar {
  height: 8px;
  background-color: var(--surface-light);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
  border: 1px solid var(--border-color);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  transition: width 0.5s ease;
  box-shadow: 0 0 8px var(--accent-glow);
}

.progress-fill.silver {
  background: linear-gradient(90deg, var(--silver-primary) 0%, var(--silver-secondary) 100%);
  box-shadow: 0 0 8px var(--silver-glow);
}

/* ============================================================
   22. ALERTS
   ============================================================ */
.alert-card {
  background: linear-gradient(135deg, var(--surface-light) 0%, var(--surface-color) 100%);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  transition: all 0.3s;
}

.alert-card:hover {
  border-color: var(--accent-primary);
  transform: translateX(4px);
  box-shadow: 0 4px 12px var(--shadow);
}

.alert-card.triggered {
  border-color: var(--error);
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.15) 0%, rgba(153, 27, 27, 0.05) 100%);
  box-shadow: 0 0 12px rgba(220, 38, 38, 0.3);
}

.alert-form-container {
  background-color: var(--surface-light);
  border-color: var(--border-color);
}

/* ============================================================
   23. NOTIFICATION STATUS
   ============================================================ */
.notif-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
}

.notif-status.granted {
  background-color: rgba(16, 185, 129, 0.2);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.notif-status.denied {
  background-color: rgba(239, 68, 68, 0.2);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.notif-status.default {
  background-color: var(--accent-glow);
  color: var(--accent-primary);
  border: 1px solid var(--accent-border);
}

/* ============================================================
   24. THEME SWITCH
   ============================================================ */
.theme-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--surface-light);
  transition: 0.3s;
  border-radius: 28px;
  border: 1.5px solid var(--border-light);
}

.theme-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 6px var(--accent-glow);
}

.theme-switch input:checked + .theme-slider {
  background-color: var(--accent-glow);
  border-color: var(--accent-primary);
}

.theme-switch input:checked + .theme-slider:before {
  transform: translateX(24px);
  background: #000000;
}

/* ============================================================
   25. SETTINGS
   ============================================================ */
.settings-item {
  background-color: var(--surface-light);
  border-color: var(--border-color);
}

.settings-icon {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
}

.settings-icon svg {
  color: #000000;
}

/* ============================================================
   26. PORTFOLIO CARDS
   ============================================================ */
.invested-card {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05)) !important;
  border-color: rgba(16, 185, 129, 0.3) !important;
}

.current-card {
  background: linear-gradient(135deg, var(--accent-glow), rgba(212, 175, 55, 0.05)) !important;
  border-color: var(--accent-border) !important;
}

.pl-card {
  background-color: var(--surface-light);
  border-color: var(--border-color);
}

.month-badge {
  background: var(--accent-glow);
  color: var(--accent-primary);
  border: 1px solid var(--accent-border);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
}

/* ============================================================
   27. VIEW SECTIONS
   ============================================================ */
.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view-section.active {
  display: block;
}

/* ============================================================
   28. SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track { background: var(--bg-color); }

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover { background: var(--accent-secondary); }

/* ============================================================
   29. HEADINGS
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  letter-spacing: 0.3px;
  font-weight: 800;
  color: var(--text-primary);
}

/* ============================================================
   30. RESPONSIVE BREAKPOINTS
   ============================================================ */
@media (min-width: 640px) {
  .sm\:inline { display: inline !important; }
  .sm\:hidden { display: none !important; }
  .sm\:block { display: block !important; }
  .sm\:flex-row { flex-direction: row; }
}

@media (min-width: 768px) {
  .md\:block { display: block !important; }
  .md\:flex { display: flex !important; }
  .md\:hidden { display: none !important; }
}

@media (min-width: 1024px) {
  .lg\:hidden { display: none !important; }
  .lg\:block { display: block !important; }
  .lg\:inline { display: inline !important; }
  .lg\:flex { display: flex !important; }
  .lg\:flex-row { flex-direction: row; }
  .lg\:flex-col { flex-direction: column; }

  .lg\:items-center { align-items: center; }
  .lg\:items-start { align-items: flex-start; }
  .lg\:justify-between { justify-content: space-between; }
  .lg\:justify-start { justify-content: flex-start; }
  .lg\:justify-end { justify-content: flex-end; }

  .lg\:text-lg { font-size: 1.125rem; }
  .lg\:text-base { font-size: 1rem; }
  .lg\:text-sm { font-size: 0.875rem; }
  .lg\:text-xs { font-size: 0.75rem; }
  .lg\:text-\[10px\] { font-size: 10px; }
  .lg\:text-\[11px\] { font-size: 11px; }

  .lg\:h-6 { height: 1.5rem; }
  .lg\:w-6 { width: 1.5rem; }
  .lg\:w-3 { width: 12px; }
  .lg\:h-3 { height: 12px; }
  .lg\:w-32 { width: 8rem; }
  .lg\:w-auto { width: auto; }

  .lg\:px-2 { padding-left: 8px; padding-right: 8px; }
  .lg\:px-4 { padding-left: 16px; padding-right: 16px; }
  .lg\:pt-16 { padding-top: 64px; }
  .lg\:p-3 { padding: 12px; }
  .lg\:gap-2 { gap: 8px; }
  .lg\:gap-2-5 { gap: 10px; }

  .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lg\:col-span-2 { grid-column: span 2 / span 2; }
}

/* ============================================================
   31. REFRESH BUTTON
   ============================================================ */
.refresh-btn:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: #000000;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.refresh-btn:not(:disabled):hover {
  box-shadow: 0 6px 16px var(--accent-glow);
  transform: translateY(-2px);
}

.refresh-btn:not(:disabled):active {
  transform: scale(0.97);
}

.refresh-btn:disabled {
  background: var(--surface-light);
  color: var(--text-tertiary);
  box-shadow: none;
}

/* ============================================================
   32. MONTHLY PNL TABLE
   ============================================================ */
#view-monthly-pnl .overflow-x-auto {
  overflow-x: hidden;
}

#view-monthly-pnl table {
  table-layout: fixed;
  width: 100%;
  border-collapse: collapse;
}

#view-monthly-pnl th:nth-child(1),
#view-monthly-pnl td:nth-child(1) { width: 28%; }

#view-monthly-pnl th:nth-child(2),
#view-monthly-pnl td:nth-child(2) { width: 24%; }

#view-monthly-pnl th:nth-child(3),
#view-monthly-pnl td:nth-child(3) { width: 24%; }

#view-monthly-pnl th:nth-child(4),
#view-monthly-pnl td:nth-child(4) { width: 24%; }

#view-monthly-pnl th,
#view-monthly-pnl td {
  padding: 10px 4px;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
}

#view-monthly-pnl thead th {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.3;
  vertical-align: bottom;
  border-bottom: 1px solid var(--border-light);
  text-wrap: balance;
}

#view-monthly-pnl tbody td {
  font-size: 0.7rem;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--border-color);
}

#view-monthly-pnl th:first-child,
#view-monthly-pnl td:first-child {
  text-align: left;
  padding-left: 6px;
  font-weight: 600;
  color: var(--text-primary);
}

#view-monthly-pnl th:last-child,
#view-monthly-pnl td:last-child {
  padding-right: 6px;
}

#view-monthly-pnl tbody tr:last-child td {
  border-bottom: none;
}

/* ============================================================
   33. ACCENT COLOR OVERRIDES
   ============================================================ */
#view-monthly-pnl tbody td:nth-child(3) {
  color: var(--accent-primary) !important;
}

.current-card > p:nth-of-type(2) {
  color: var(--accent-primary) !important;
}

/* ============================================================
   34. CALCULATOR METAL TOGGLE
   ============================================================ */
.calc-metal-toggle {
  display: flex;
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  background-color: var(--surface-light);
  border: 1px solid var(--border-color);
}

.calc-metal-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  min-height: 26px;
  white-space: nowrap;
}

.calc-metal-btn:hover {
  color: var(--text-primary);
}

#calc-metal-gold.active {
  background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-secondary) 100%);
  color: #000000;
  box-shadow: 0 2px 4px var(--gold-glow);
}

#calc-metal-silver.active {
  background: linear-gradient(135deg, var(--silver-primary) 0%, var(--silver-secondary) 100%);
  color: #000000;
  box-shadow: 0 2px 4px var(--silver-glow);
}

.calc-metal-btn.active {
  color: #000000;
}

.calc-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  flex-wrap: nowrap;
  min-width: 0;
}

@media (min-width: 1024px) {
  .calc-controls-row {
    width: auto;
    min-width: 320px;
    gap: 24px;
  }
}

@media (max-width: 400px) {
  .calc-metal-btn {
    padding: 4px 8px;
    font-size: 0.62rem;
    min-height: 24px;
  }
  .karat-tab {
    padding: 5px 8px;
    font-size: 0.7rem;
    min-height: 32px;
  }
}

#calc-purity-tabs.silver-active .karat-tab.active {
  background: linear-gradient(135deg, var(--silver-primary) 0%, var(--silver-secondary) 100%);
  color: #000000;
  border-color: var(--silver-primary);
  box-shadow: 0 2px 8px var(--silver-glow);
}

.unit-toggle.silver-active .unit-btn.active {
  background: linear-gradient(135deg, var(--silver-primary) 0%, var(--silver-secondary) 100%);
  color: #000000;
  box-shadow: 0 2px 6px var(--silver-glow);
}

/* ============================================================
   35. ALERT METAL SELECTOR
   ============================================================ */
#alert-metal-gold.active,
#alert-metal-silver.active {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: #000000;
  border-color: var(--accent-primary);
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ============================================================
   36. ADD ENTRY BUTTON (Bottom Nav)
   ============================================================ */
.add-entry-btn {
  border-radius: 9999px;
  padding: 8px;
  margin-top: -20px;
  border: 4px solid var(--bg-color);
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* ============================================================
   37. TRANSACTIONS — Card-Based Layout
   ============================================================ */
#transactions-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 768px) {
  #transactions-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  #transactions-container {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.txn-card {
  background: linear-gradient(135deg, var(--surface-light) 0%, var(--surface-color) 100%);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px;
  transition: all 0.2s ease;
}

.txn-card:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 4px 12px var(--shadow), 0 0 12px var(--accent-glow);
}

.txn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.txn-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.txn-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.txn-badge-buy {
  background: rgba(5, 150, 105, 0.2);
  color: var(--success);
  border: 1px solid rgba(5, 150, 105, 0.4);
}

.txn-badge-sell {
  background: rgba(220, 38, 38, 0.2);
  color: var(--error);
  border: 1px solid rgba(220, 38, 38, 0.4);
}

.txn-badge-gold {
  background: var(--gold-glow);
  color: var(--gold-primary);
  border: 1px solid var(--border-gold);
  font-weight: 700;
}

.txn-badge-silver {
  background: rgba(226, 232, 240, 0.15);
  color: var(--silver-primary);
  border: 1px solid var(--border-silver);
  font-weight: 700;
}

.txn-date {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.txn-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 6px 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 6px;
}

.txn-grid > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.txn-label {
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.txn-value {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.txn-notes {
  font-size: 0.65rem;
  color: var(--text-secondary);
  font-style: italic;
  padding: 4px 0;
  border-top: 1px dashed var(--border-color);
  margin-top: 3px;
  word-break: break-word;
}

.txn-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.txn-pl-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.txn-pl {
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.txn-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.txn-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: var(--surface-color);
  color: var(--text-primary);
  font-size: 0.65rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 28px;
  font-family: inherit;
}

.txn-action-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.txn-action-btn.delete:hover {
  border-color: var(--error);
  color: var(--error);
}

/* ============================================================
   38. PWA-SPECIFIC STYLES (Only when installed as app)
   ============================================================ */
@media (display-mode: standalone) {
  /* Install section hidden — already installed */
  #install-app-btn,
  .settings-item .install-section {
    display: none !important;
  }

  /* App-like feel: disable text selection on chrome (not inputs) */
  .app-header,
  .bottom-nav,
  .sidebar,
  .tracker-controls,
  .tab-container,
  .metal-toggle,
  .calc-metal-toggle,
  .unit-toggle,
  .karat-tab,
  .nav-item,
  .btn,
  .toggle-btn {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  /* Prevent long-press context menu on chrome elements */
  .app-header, .bottom-nav, .sidebar {
    -webkit-touch-callout: none;
  }
}

/* ============================================================
   39. BROWSER-SPECIFIC STYLES (Regular browser)
   ============================================================ */
@media (display-mode: browser) {
  /* Install section visible */
  #install-app-btn {
    display: inline-flex;
  }
}

/* ============================================================
   40. RESPECT REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   41. MATCHED PURCHASE INFO (Sale Form + Transaction Card)
   ============================================================ */
.txn-match-info {
  font-size: 0.65rem;
  color: var(--accent-primary);
  padding: 4px 0;
  font-weight: 600;
  font-style: italic;
  border-top: 1px dashed var(--border-color);
  margin-top: 3px;
}

#match-purchase-section {
  background-color: var(--surface-light);
  border: 1px dashed var(--accent-border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
}

#match-purchase-section select {
  background-color: var(--surface-color);
}

#portfolio-pl-breakdown > div {
  padding: 1px 0;
}

/* ============================================================
   42. MULTI-PURCHASE MATCH LIST (Sale Form)
   ============================================================ */
.match-purchases-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  padding: 2px;
}

.match-purchase-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: var(--surface-color);
}

.match-purchase-item:hover {
  border-color: var(--accent-primary);
  background-color: var(--surface-light);
}

.match-purchase-item:has(.match-purchase-checkbox:checked) {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, var(--accent-glow) 0%, rgba(212,175,55,0.05) 100%);
  box-shadow: 0 0 8px var(--accent-glow);
}

.match-purchase-checkbox {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.match-purchase-item-body {
  flex: 1;
  min-width: 0;
}

.match-purchase-item-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.match-purchase-item-subtitle {
  font-size: 0.65rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Match purchase item — available line */
.match-purchase-item-available {
  font-size: 0.65rem;
  color: var(--success);
  font-weight: 600;
  margin-top: 3px;
}

.match-purchase-item-available strong {
  color: var(--success);
  font-weight: 800;
}

.match-purchase-item-available .text-tertiary {
  color: var(--text-tertiary);
  font-weight: 500;
}