/* =========================================================================
   Financial Market Dashboard — Stylesheet
   Vanilla CSS3, CSS variables, mobile-first, RTL, light/dark mode.
   ========================================================================= */

/* ---------------------------------------------------------------------
   1. Design tokens
   --------------------------------------------------------------------- */
:root {
  /* Brand palette (as specified) */
  --color-primary: #2563EB;
  --color-primary-600: #1D4ED8;
  --color-accent: #06B6D4;
  --color-gold: #F59E0B;
  --color-success: #10B981;
  --color-danger: #EF4444;

  --color-text: #111827;
  --color-text-secondary: #6B7280;
  --color-bg: #F8FAFC;
  --color-surface: #FFFFFF;
  --color-surface-glass: rgba(255, 255, 255, 0.72);
  --color-border: #E5E7EB;

  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04), 0 1px 1px rgba(17, 24, 39, 0.03);
  --shadow-md: 0 8px 24px -8px rgba(17, 24, 39, 0.12), 0 2px 6px rgba(17, 24, 39, 0.05);
  --shadow-lg: 0 20px 45px -15px rgba(17, 24, 39, 0.22);
  --shadow-glow-primary: 0 0 0 1px rgba(37, 99, 235, 0.12), 0 8px 30px -10px rgba(37, 99, 235, 0.35);
  --shadow-glow-gold: 0 0 0 1px rgba(245, 158, 11, 0.14), 0 8px 30px -10px rgba(245, 158, 11, 0.35);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --font-sans: 'Vazirmatn', 'Segoe UI', Tahoma, system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Consolas', monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 140ms;
  --dur-base: 220ms;
  --dur-slow: 420ms;

  --header-h: 68px;
  --container-w: 1360px;
}

[data-theme='dark'] {
  --color-primary: #3B82F6;
  --color-primary-600: #60A5FA;
  --color-accent: #22D3EE;
  --color-gold: #FBBF24;
  --color-success: #34D399;
  --color-danger: #F87171;

  --color-text: #F3F4F6;
  --color-text-secondary: #9CA3AF;
  --color-bg: #0A0F1C;
  --color-surface: #101828;
  --color-surface-glass: rgba(16, 24, 40, 0.66);
  --color-border: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 50px -15px rgba(0, 0, 0, 0.65);
  --shadow-glow-primary: 0 0 0 1px rgba(59, 130, 246, 0.25), 0 8px 30px -10px rgba(59, 130, 246, 0.5);
  --shadow-glow-gold: 0 0 0 1px rgba(251, 191, 36, 0.22), 0 8px 30px -10px rgba(251, 191, 36, 0.45);
}

/* ---------------------------------------------------------------------
   2. Reset & base
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  direction: rtl;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--font-sans);
  color: var(--color-text);
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(37, 99, 235, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(6, 182, 212, 0.08), transparent 55%),
    var(--color-bg);
  background-attachment: fixed;
  transition: background-color var(--dur-base) var(--ease-standard), color var(--dur-base) var(--ease-standard);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
button { font-family: inherit; }
a { color: inherit; }

::selection { background: rgba(37, 99, 235, 0.22); }

/* Scrollbar (webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-secondary); }

.container {
  max-width: var(--container-w);
  margin-inline: auto;
  padding-inline: 20px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------------------------------------------------------------------
   3. Glass surface utility
   --------------------------------------------------------------------- */
.glass {
  background: var(--color-surface-glass);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--color-border);
}

/* ---------------------------------------------------------------------
   4. Header
   --------------------------------------------------------------------- */
.header-wrap {
  position: sticky;
  top: 0;
  z-index: 40;
  animation: fadeSlideDown var(--dur-slow) var(--ease-out) both;
}

.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-glass);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}

.header-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding-block: 8px;
}

.brand-logo {
  height: 26px;
  width: auto;
  display: block;
}

[data-theme='dark'] .brand-logo.logo-light { display: none; }
[data-theme='dark'] .brand-logo.logo-dark { display: block; }
.brand-logo.logo-dark { display: none; }

.theme-toggle-slot {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.update-strip-wrap {
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.update-strip {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: -1px;
  padding: 4px 16px 5px;
  border-radius: 0 0 var(--radius-pill) var(--radius-pill);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: none;
  font-size: 10.5px;
  color: var(--color-text-secondary);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  user-select: none;
  transition: background var(--dur-fast) var(--ease-standard);
}
.update-strip:hover { background: var(--color-bg); }
.update-strip:active { transform: scale(0.97); }

.update-strip .status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--color-text-secondary);
  flex-shrink: 0;
}
.update-strip[data-status='online'] .status-dot { background: var(--color-success); animation: pulseDot 2.2s ease-in-out infinite; }
.update-strip[data-status='error'] .status-dot { background: var(--color-danger); }
.update-strip[data-status='loading'] .status-dot { background: var(--color-gold); animation: pulseDot 1.1s ease-in-out infinite; }
.update-strip.is-loading { opacity: 0.6; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-fast) var(--ease-standard),
              background var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard);
}

.icon-btn svg { width: 18px; height: 18px; }

.icon-btn:hover { border-color: var(--color-primary); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0) scale(0.94); }

.icon-btn.is-loading svg { animation: spin 0.85s linear infinite; }

/* ---------------------------------------------------------------------
   5. Main layout / section titles
   --------------------------------------------------------------------- */
main { padding-block: 14px 40px; }

.panel {
  border-radius: var(--radius-lg);
  padding: 16px;
  background: var(--color-surface-glass);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
}

@media (min-width: 640px) {
  .panel { padding: 22px; }
}

.section {
  margin-top: 16px;
  animation: fadeSlideUp var(--dur-slow) var(--ease-out) both;
}

main > .section:first-child { margin-top: 0; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
}

.section-sub {
  font-size: 12.5px;
  color: var(--color-text-secondary);
  margin: 0;
}

/* ---------------------------------------------------------------------
   6. Featured overview cards
   --------------------------------------------------------------------- */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

@media (min-width: 640px) {
  .overview-grid { gap: 14px; }
}

.featured-card {
  position: relative;
  min-width: 0;
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 128px;
  background: var(--color-surface-glass);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: fadeSlideUp var(--dur-slow) var(--ease-out) both;
}

@media (min-width: 640px) {
  .featured-card { padding: 18px 16px; min-height: 154px; }
}

.featured-card::before {
  content: '';
  position: absolute;
  inset: -40% -20% auto auto;
  width: 220px; height: 220px;
  background: radial-gradient(circle, var(--glow-color, var(--color-primary)) 0%, transparent 70%);
  opacity: 0.18;
  pointer-events: none;
}

.featured-card[data-kind='gold'] { --glow-color: var(--color-gold); }
.featured-card[data-kind='fiat'] { --glow-color: var(--color-primary); }
.featured-card[data-kind='crypto'] { --glow-color: var(--color-accent); }

.featured-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  min-width: 0;
}

.featured-top > div { min-width: 0; }

.featured-name { font-size: 12px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.featured-symbol { font-size: 10px; color: var(--color-text-secondary); margin: 0; }

.featured-price {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 2px 0 2px;
  direction: ltr;
  text-align: right;
}

@media (min-width: 640px) {
  .featured-name { font-size: 13.5px; }
  .featured-symbol { font-size: 11.5px; }
  .featured-price { font-size: 24px; margin-bottom: 8px; }
}

.featured-price-usd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-secondary);
  direction: ltr;
  text-align: right;
  margin-bottom: 8px;
}

.featured-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.featured-time {
  font-size: 10px;
  color: var(--color-text-secondary);
  display: none;
}

@media (min-width: 640px) {
  .featured-time { display: inline; font-size: 11px; }
}

/* ---------------------------------------------------------------------
   7. Avatars / coin marks
   --------------------------------------------------------------------- */
.coin-avatar {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 10.5px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--av-1, var(--color-primary)), var(--av-2, var(--color-accent)));
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--av-1, var(--color-primary)) 60%, transparent);
}

[data-category='gold'] .coin-avatar { --av-1: var(--color-gold); --av-2: #FCD34D; }
[data-category='fiat'] .coin-avatar { --av-1: var(--color-primary); --av-2: var(--color-accent); }
[data-category='crypto'] .coin-avatar { --av-1: #7C3AED; --av-2: var(--color-accent); }

.featured-card .coin-avatar { width: 34px; height: 34px; border-radius: 10px; font-size: 10.5px; }

@media (min-width: 640px) {
  .coin-avatar { width: 38px; height: 38px; border-radius: 11px; font-size: 12px; }
  .featured-card .coin-avatar { width: 42px; height: 42px; border-radius: 12px; font-size: 12.5px; }
}

/* ---------------------------------------------------------------------
   8. Change badges
   --------------------------------------------------------------------- */
.change-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  font-size: 9.5px;
  font-weight: 700;
  font-family: var(--font-mono);
  direction: ltr;
  white-space: nowrap;
}

.change-badge svg { width: 9px; height: 9px; }

.change-badge.up { color: var(--color-success); background: color-mix(in srgb, var(--color-success) 14%, transparent); }
.change-badge.down { color: var(--color-danger); background: color-mix(in srgb, var(--color-danger) 14%, transparent); }
.change-badge.flat { color: var(--color-text-secondary); background: color-mix(in srgb, var(--color-text-secondary) 12%, transparent); }

/* ---------------------------------------------------------------------
   9. Tabs (navigation)
   --------------------------------------------------------------------- */
.tabs {
  position: relative;
  display: flex;
  width: 100%;
  gap: 2px;
  padding: 4px;
  margin-top: 14px;
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  overflow-x: auto;
}

.tab-btn {
  position: relative;
  z-index: 1;
  padding: 9px 16px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-weight: 700;
  font-size: 13px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-base) var(--ease-standard);
}

.tab-btn.is-active { color: #fff; }

.tab-indicator {
  position: absolute;
  top: 4px; bottom: 4px;
  right: 0;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  box-shadow: var(--shadow-glow-primary);
  transition: right var(--dur-base) var(--ease-out), width var(--dur-base) var(--ease-out);
  z-index: 0;
}

/* ---------------------------------------------------------------------
   10. Toolbar: search / sort / filter
   --------------------------------------------------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.search-field {
  position: relative;
  width: 100%;
  margin-top: 14px;
}

.search-field svg {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  color: var(--color-text-secondary);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  padding: 12px 14px;
  padding-inline-start: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
}

.search-field input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary) 16%, transparent);
  outline: none;
}

.select-field {
  position: relative;
  flex-shrink: 0;
}

.select-field svg {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--color-text-secondary);
  pointer-events: none;
}

.select-field select {
  appearance: none;
  padding: 10px 30px 10px 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  min-width: 128px;
}

.select-field::after {
  content: '';
  position: absolute;
  inset-inline-end: 12px;
  top: 50%;
  width: 7px; height: 7px;
  border-inline-end: 2px solid var(--color-text-secondary);
  border-bottom: 2px solid var(--color-text-secondary);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

.chip-group {
  display: inline-flex;
  gap: 6px;
  padding: 3px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}

.chip-btn {
  border: none;
  background: transparent;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}

.chip-btn.is-active { background: var(--color-text); color: var(--color-surface); }
[data-theme='dark'] .chip-btn.is-active { background: var(--color-primary); color: #fff; }

/* ---------------------------------------------------------------------
   11. Asset list & rows (single-column, compact horizontal rows)
   --------------------------------------------------------------------- */
.asset-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
}

.asset-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  background: var(--color-surface-glass);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: right;
  opacity: 0;
  transform: translateY(10px);
  animation: cardEnter var(--dur-slow) var(--ease-out) forwards;
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.asset-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--color-primary) 35%, var(--color-border));
}

.asset-card:active { transform: translateY(0) scale(0.997); }

.asset-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
  flex: 1 1 auto;
}

.asset-identity { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }

.asset-names { min-width: 0; }
.asset-name-fa { font-size: 12.5px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-name-en { font-size: 10px; color: var(--color-text-secondary); margin: 1px 0 0; direction: ltr; text-align: right; white-space: nowrap; }

.asset-price-row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
}

.asset-card-end {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.asset-price {
  font-family: var(--font-mono);
  font-size: 14.5px;
  font-weight: 700;
  direction: ltr;
  text-align: right;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-standard);
  border-radius: 8px;
}

.asset-unit { font-size: 9.5px; color: var(--color-text-secondary); margin-inline-start: 3px; font-weight: 500; }

.asset-price-usd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-secondary);
  direction: ltr;
  text-align: right;
  white-space: nowrap;
  margin-top: 1px;
}

.asset-card-foot {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}

.asset-change-amount {
  font-size: 9.5px;
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
  direction: ltr;
  white-space: nowrap;
}

/* Price flash animation on update */
@keyframes flashGreen {
  0% { background-color: color-mix(in srgb, var(--color-success) 28%, transparent); }
  100% { background-color: transparent; }
}
@keyframes flashRed {
  0% { background-color: color-mix(in srgb, var(--color-danger) 28%, transparent); }
  100% { background-color: transparent; }
}
.asset-price.flash-up { animation: flashGreen 900ms var(--ease-standard); }
.asset-price.flash-down { animation: flashRed 900ms var(--ease-standard); }

/* ---------------------------------------------------------------------
   12. Skeleton loaders
   --------------------------------------------------------------------- */
.skeleton-card {
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  height: 140px;
  overflow: hidden;
  position: relative;
}

.skeleton-line {
  border-radius: 8px;
  background: var(--color-border);
  position: relative;
  overflow: hidden;
}
.skeleton-line::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--color-surface) 70%, #fff 30%), transparent);
  animation: shimmer 1.5s infinite;
}
[data-theme='dark'] .skeleton-line::after {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
}

.skeleton-avatar { width: 40px; height: 40px; border-radius: 12px; margin-bottom: 14px; }
.skeleton-title { width: 60%; height: 14px; margin-bottom: 8px; }
.skeleton-sub { width: 40%; height: 10px; margin-bottom: 18px; }
.skeleton-price { width: 75%; height: 20px; }

/* ---------------------------------------------------------------------
   13. Empty & error states
   --------------------------------------------------------------------- */
.state-panel {
  grid-column: 1 / -1;
  text-align: center;
  padding: 52px 20px;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--color-border);
  color: var(--color-text-secondary);
  animation: fadeSlideUp var(--dur-base) var(--ease-out) both;
}

.state-panel svg { width: 40px; height: 40px; margin: 0 auto 12px; color: var(--color-text-secondary); }
.state-panel h3 { margin: 0 0 6px; color: var(--color-text); font-size: 14.5px; }
.state-panel p { margin: 0; font-size: 12.5px; }

.state-panel .retry-btn {
  margin-top: 16px;
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
  background: transparent;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard), transform var(--dur-fast);
}
.state-panel .retry-btn:hover { background: var(--color-primary); color: #fff; }
.state-panel .retry-btn:active { transform: scale(0.96); }

/* ---------------------------------------------------------------------
   14. Toasts
   --------------------------------------------------------------------- */
.toast-region {
  position: fixed;
  z-index: 100;
  bottom: 18px;
  inset-inline: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding-inline: 16px;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 380px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-glass);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  animation: toastIn var(--dur-base) var(--ease-out) both;
}

.toast.is-leaving { animation: toastOut var(--dur-base) var(--ease-standard) forwards; }

.toast-icon { width: 20px; height: 20px; flex-shrink: 0; }
.toast[data-type='success'] .toast-icon { color: var(--color-success); }
.toast[data-type='error'] .toast-icon { color: var(--color-danger); }
.toast[data-type='info'] .toast-icon { color: var(--color-primary); }

/* ---------------------------------------------------------------------
   15. Modal (desktop) / Bottom sheet (mobile)
   --------------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(10, 14, 25, 0.5);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-standard);
}
.overlay.is-open { opacity: 1; pointer-events: auto; }

.detail-panel {
  position: fixed;
  z-index: 91;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  opacity: 0;
  pointer-events: none;
}

/* Desktop: centered modal */
@media (min-width: 720px) {
  .detail-panel {
    top: 50%; left: 50%;
    width: min(420px, 92vw);
    border-radius: var(--radius-lg);
    transform: translate(-50%, -46%) scale(0.96);
    transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out);
  }
  .detail-panel.is-open {
    opacity: 1; pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Mobile: bottom sheet */
@media (max-width: 719.98px) {
  .detail-panel {
    left: 0; right: 0; bottom: 0;
    width: 100%;
    border-radius: 24px 24px 0 0;
    transform: translateY(100%);
    transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out);
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }
  .detail-panel.is-open {
    opacity: 1; pointer-events: auto;
    transform: translateY(0);
  }
  .sheet-handle {
    width: 40px; height: 4px;
    border-radius: var(--radius-pill);
    background: var(--color-border);
    margin: -8px auto 14px;
  }
}

.sheet-handle { display: none; }
@media (max-width: 719.98px) { .sheet-handle { display: block; } }

.detail-close {
  position: absolute;
  top: 14px;
  inset-inline-end: 14px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.detail-close svg { width: 15px; height: 15px; }

.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.detail-head .coin-avatar { width: 48px; height: 48px; border-radius: 14px; font-size: 14px; }
.detail-head h3 { margin: 0; font-size: 16px; }
.detail-head p { margin: 2px 0 0; font-size: 12px; color: var(--color-text-secondary); direction: ltr; text-align: right; }

.detail-price { font-family: var(--font-mono); font-size: 28px; font-weight: 800; direction: ltr; text-align: right; margin-bottom: 14px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-stat {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--color-bg);
}
[data-theme='dark'] .detail-stat { background: rgba(255,255,255,0.03); }

.detail-stat span { display: block; font-size: 11px; color: var(--color-text-secondary); margin-bottom: 4px; }
.detail-stat strong { font-family: var(--font-mono); font-size: 14px; direction: ltr; display: block; }

/* ---------------------------------------------------------------------
   16. Footer
   --------------------------------------------------------------------- */
.site-footer {
  text-align: center;
  padding: 26px 16px 40px;
  color: var(--color-text-secondary);
  font-size: 12px;
}

/* ---------------------------------------------------------------------
   17. Keyframes
   --------------------------------------------------------------------- */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); }
  50% { box-shadow: 0 0 0 5px transparent; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 100% { transform: translateX(100%); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px) scale(0.97); } }

/* Ripple */
.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  animation: rippleAnim 600ms var(--ease-standard);
  background: currentColor;
  opacity: 0.25;
  pointer-events: none;
}
@keyframes rippleAnim { to { transform: scale(2.6); opacity: 0; } }

/* ---------------------------------------------------------------------
   18. Reduced motion
   --------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}