/* ═══════════════════════════════════════════════════════════════
   RS3 Flip Tool — Premium Dark Theme
   RuneScape-inspired design with gold accents & glassmorphism
   ═══════════════════════════════════════════════════════════════ */

/* ─── CSS Custom Properties ──────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-primary: #06060b;
  --bg-secondary: #0c0c15;
  --bg-tertiary: #10101c;
  --bg-card: rgba(12, 12, 22, 0.82);
  --bg-card-hover: rgba(18, 18, 32, 0.95);
  --bg-input: rgba(10, 10, 20, 0.7);
  --bg-header: rgba(8, 8, 14, 0.92);

  /* Gold palette */
  --gold: #d4a017;
  --gold-light: #f0c040;
  --gold-bright: #ffd700;
  --gold-dim: #8b6914;
  --gold-glow: rgba(212, 160, 23, 0.25);
  --gold-border: rgba(212, 160, 23, 0.15);
  --gold-bg: rgba(212, 160, 23, 0.06);

  /* Accent */
  --green: #00d4aa;
  --green-light: #2eec88;
  --green-dim: rgba(0, 212, 170, 0.12);
  --red: #ff4f5e;
  --red-light: #ff7b86;
  --red-dim: rgba(255, 79, 94, 0.12);
  --blue: #4da6ff;
  --blue-dim: rgba(77, 166, 255, 0.12);

  /* Text */
  --text-primary: #e8e6e3;
  --text-secondary: #9b97a3;
  --text-muted: #5c586a;
  --text-inverse: #0a0a0f;

  /* Glass */
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-blur: 16px;

  /* Typography */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;

  /* Sizes */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.45);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.55);
  --shadow-gold: 0 0 24px rgba(212, 160, 23, 0.12);
  --shadow-glow: 0 0 40px rgba(212, 160, 23, 0.08);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(212, 160, 23, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(0, 212, 170, 0.02) 0%, transparent 50%),
    radial-gradient(ellipse 50% 40% at 10% 80%, rgba(77, 166, 255, 0.02) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

body > * { position: relative; z-index: 1; }

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

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

/* Utility */
.gold { color: var(--gold-light); }
.red { color: var(--red); }
.green { color: var(--green); }
.mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(212, 160, 23, 0.2);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(212, 160, 23, 0.35); }

/* ─── Header ─────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--gold-border);
  box-shadow: var(--shadow-glow);
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 8px rgba(212, 160, 23, 0.3));
  animation: logoGlow 3s ease-in-out infinite;
}

@keyframes logoGlow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(212, 160, 23, 0.3)); }
  50% { filter: drop-shadow(0 0 16px rgba(212, 160, 23, 0.6)); }
}

.logo-text {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.logo-text .gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-bright));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-stats {
  display: flex;
  gap: 24px;
}

.header-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.header-stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 500;
}

.header-stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.92rem;
}

/* ─── Navigation Tabs ──────────────────────────────────────────── */
.nav-tabs {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 64px; /* Below header */
  z-index: 99;
}

.nav-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.nav-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 16px 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--duration-fast);
}

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

.nav-btn.active {
  color: var(--gold-light);
  border-bottom-color: var(--gold);
  background: linear-gradient(to top, rgba(212, 160, 23, 0.1), transparent);
}

/* ─── Tab Content ────────────────────────────────────────────── */
.tab-pane {
  display: none;
  animation: fadeIn var(--duration-normal) var(--ease-out);
}
.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hub-header {
  margin-bottom: 24px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 16px;
}
.hub-header h2 { font-size: 1.4rem; color: var(--gold-light); margin-bottom: 4px; }

.pvm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.pvm-card-body { padding: 20px; }
.pvm-card-body p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.6; }
.mt-10 { margin-top: 14px; display: inline-block; }

/* ─── Controls (Search + Filters) ────────────────────────────── */
.controls {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--glass-border);
  padding: 16px 0;
}

.controls-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-container {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--duration-normal);
}

.search-input {
  width: 100%;
  padding: 12px 80px 12px 46px;
  font-family: var(--font-main);
  font-size: 0.95rem;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  outline: none;
  transition: all var(--duration-normal) var(--ease-out);
}

.search-input:focus {
  border-color: var(--gold-border);
  box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.08), var(--shadow-gold);
  background: rgba(14, 14, 24, 0.9);
}

.search-input:focus + .search-icon,
.search-container:focus-within .search-icon {
  color: var(--gold);
}

.search-input::placeholder { color: var(--text-muted); }

.search-count {
  position: absolute;
  right: 16px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-group label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.filter-select {
  padding: 8px 32px 8px 12px;
  font-family: var(--font-main);
  font-size: 0.82rem;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239b97a3' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all var(--duration-fast);
}

.filter-select:hover { border-color: var(--gold-border); }
.filter-select:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(212,160,23,0.1); }

.filter-select-sm { padding: 6px 28px 6px 10px; font-size: 0.78rem; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  white-space: nowrap;
}

.btn-gold {
  background: linear-gradient(135deg, rgba(212, 160, 23, 0.15), rgba(212, 160, 23, 0.05));
  border-color: var(--gold-border);
  color: var(--gold-light);
}

.btn-gold:hover {
  background: linear-gradient(135deg, rgba(212, 160, 23, 0.25), rgba(212, 160, 23, 0.1));
  border-color: var(--gold);
  box-shadow: var(--shadow-gold);
  transform: translateY(-1px);
}

.btn-gold:active { transform: translateY(0); }

.btn-icon-text {
  font-size: 1rem;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-xs);
  transition: all var(--duration-fast);
  opacity: 0.6;
}

.btn-icon:hover { opacity: 1; transform: scale(1.15); }

/* ─── Main Layout ────────────────────────────────────────────── */
.main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

.content-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

/* ─── Items Section ──────────────────────────────────────────── */
.items-section {
  min-height: 500px;
}

.items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.items-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.items-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.items-per-page {
  display: flex;
  align-items: center;
  gap: 6px;
}

.items-per-page label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 2px 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--gold-bg);
  color: var(--gold-light);
  border: 1px solid var(--gold-border);
  border-radius: 100px;
}

.badge-sm { min-width: 22px; padding: 1px 7px; font-size: 0.68rem; }

/* ─── Items Grid ─────────────────────────────────────────────── */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

/* ─── Item Card ──────────────────────────────────────────────── */
.item-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: cardFadeIn var(--duration-slow) var(--ease-out) both;
}

.item-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--gold-border);
  box-shadow: var(--shadow-gold), var(--shadow-sm);
  transform: translateY(-2px);
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.item-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.item-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  image-rendering: pixelated;
  border-radius: var(--radius-xs);
  background: rgba(255,255,255,0.03);
  padding: 2px;
}

.item-name {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.item-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.item-price {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--gold-light);
}

.item-price.no-price {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 400;
}

.item-trend {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
}

.item-trend.up {
  color: var(--green);
  background: var(--green-dim);
}

.item-trend.down {
  color: var(--red);
  background: var(--red-dim);
}

.item-trend.neutral {
  color: var(--text-muted);
  background: rgba(92, 88, 106, 0.12);
}

.item-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--duration-fast);
}

.item-card:hover .item-actions { opacity: 1; }

.item-action-btn {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xs);
  padding: 3px 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--duration-fast);
  line-height: 1;
}

.item-action-btn:hover {
  background: rgba(212, 160, 23, 0.2);
  border-color: var(--gold-border);
  transform: scale(1.1);
}

.item-action-btn.active {
  background: var(--gold-bg);
  border-color: var(--gold);
}

.item-members-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: rgba(77, 166, 255, 0.1);
  color: var(--blue);
  border: 1px solid rgba(77, 166, 255, 0.15);
}

.item-limit-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: rgba(212, 160, 23, 0.06);
  color: var(--gold-dim);
  border: 1px solid rgba(212, 160, 23, 0.1);
  font-family: var(--font-mono);
}

/* ─── Loading ────────────────────────────────────────────────── */
.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 20px;
}

.loader {
  position: relative;
  width: 56px;
  height: 56px;
}

.loader-ring {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

.loader-ring:nth-child(2) {
  inset: 6px;
  border-top-color: var(--gold-light);
  animation-duration: 0.9s;
  animation-direction: reverse;
}

.loader-ring:nth-child(3) {
  inset: 12px;
  border-top-color: var(--gold-bright);
  animation-duration: 0.6s;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.loading-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ─── No Results ─────────────────────────────────────────────── */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.no-results-icon { font-size: 2.5rem; margin-bottom: 12px; }
.no-results p { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.no-results span { font-size: 0.82rem; }

/* ─── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.page-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--gold-border);
  color: var(--text-primary);
}

.page-btn.active {
  background: linear-gradient(135deg, rgba(212, 160, 23, 0.2), rgba(212, 160, 23, 0.08));
  border-color: var(--gold);
  color: var(--gold-light);
  box-shadow: var(--shadow-gold);
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.page-ellipsis {
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 0 4px;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 84px;
}

/* ─── Panel (shared for watchlist + calculator) ──────────────── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-border);
}

.panel-header h3 {
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-icon { font-size: 1rem; }

/* ─── Watchlist Panel ────────────────────────────────────────── */
.watchlist-items {
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
}

.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-muted);
}

.empty-icon { font-size: 1.8rem; display: block; margin-bottom: 8px; }
.empty-state p { font-weight: 600; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state span { font-size: 0.75rem; }

.watchlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast);
  cursor: pointer;
}

.watchlist-item:hover { background: rgba(255, 255, 255, 0.03); }

.watchlist-item-icon {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.watchlist-item-info {
  flex: 1;
  min-width: 0;
}

.watchlist-item-name {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.watchlist-item-price {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--gold);
}

.watchlist-item-remove {
  background: none;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--duration-fast);
  padding: 2px;
}

.watchlist-item:hover .watchlist-item-remove { opacity: 0.6; }
.watchlist-item-remove:hover { opacity: 1 !important; }

/* ─── Calculator Panel ───────────────────────────────────────── */
.calculator-body {
  padding: 16px;
}

.calc-field {
  margin-bottom: 12px;
}

.calc-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.calc-input {
  width: 100%;
  padding: 9px 12px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  transition: all var(--duration-fast);
}

.calc-input:focus {
  border-color: var(--gold-border);
  box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.08);
}

.calc-input::placeholder { color: var(--text-muted); }

/* Hide number input spinners */
.calc-input::-webkit-outer-spin-button,
.calc-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.calc-input[type=number] { -moz-appearance: textfield; }

.calc-results {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--glass-border);
}

.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.8rem;
}

.calc-row span:first-child { color: var(--text-secondary); }

.calc-value {
  font-family: var(--font-mono);
  font-weight: 600;
}

.calc-row-total {
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid var(--gold-border);
  font-size: 0.9rem;
}

.calc-row-total .calc-value {
  font-size: 1rem;
  font-weight: 800;
}

.calc-note {
  margin-top: 12px;
  padding: 8px 10px;
  background: rgba(255, 79, 94, 0.06);
  border: 1px solid rgba(255, 79, 94, 0.1);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─── Modal ──────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modalFadeIn var(--duration-normal) var(--ease-out);
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 860px;
  background: var(--bg-secondary);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--shadow-gold);
  animation: modalSlideIn var(--duration-slow) var(--ease-spring);
  overflow: hidden;
}

.modal-content-sm { max-width: 520px; }

@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(0.93) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--glass-border);
}

.modal-item-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.modal-item-icon {
  width: 42px;
  height: 42px;
  image-rendering: pixelated;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  padding: 3px;
}

.modal-item-info h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.modal-close:hover {
  background: rgba(255, 79, 94, 0.12);
  border-color: rgba(255, 79, 94, 0.2);
  color: var(--red);
}

/* ─── Chart ──────────────────────────────────────────────────── */
.chart-wrapper {
  position: relative;
  padding: 20px 24px;
  min-height: 380px;
}

.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg-secondary);
  z-index: 2;
}

.chart-loading .loader-ring {
  position: relative;
  width: 40px;
  height: 40px;
  border: 2px solid transparent;
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.chart-loading p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

#price-chart {
  width: 100%;
  height: 360px;
  display: block;
}

.modal-details {
  padding: 16px 24px 20px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  border-top: 1px solid var(--glass-border);
}

.detail-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
}

.detail-stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
}

/* ─── Detail Modal Body ──────────────────────────────────────── */
.detail-body {
  padding: 20px 24px;
}

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

.detail-field {
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}

.detail-field-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.detail-field-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
}

/* ─── Toasts ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn var(--duration-slow) var(--ease-spring);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  max-width: 360px;
}

.toast.success { border-color: rgba(0, 212, 170, 0.2); }
.toast.error { border-color: rgba(255, 79, 94, 0.2); }
.toast.info { border-color: var(--gold-border); }

.toast-out {
  animation: toastOut var(--duration-normal) var(--ease-out) forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(40px) scale(0.95); }
}

/* ─── Skeleton Loading ───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.03) 25%,
    rgba(255,255,255,0.06) 50%,
    rgba(255,255,255,0.03) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  height: 100px;
  border-radius: var(--radius-md);
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .content-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

@media (max-width: 768px) {
  html { font-size: 14px; }

  .header-inner { padding: 0 16px; }
  .header-stats { gap: 14px; }
  .header-stat-label { display: none; }

  .controls-inner { padding: 0 16px; }

  .main { padding: 16px; }

  .items-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
  }

  .sidebar { grid-template-columns: 1fr; }

  .filters { gap: 8px; }
  .filter-group label { display: none; }

  .modal { padding: 12px; }
  .modal-content { border-radius: var(--radius-lg); }
}

@media (max-width: 480px) {
  .items-grid {
    grid-template-columns: 1fr 1fr;
  }

  .item-card { padding: 10px; }
  .item-icon { width: 28px; height: 28px; }
  .item-name { font-size: 0.75rem; }

  .header-stats { display: none; }
}
