:root {
  --bg: #0a0c0f;
  --bg2: #111418;
  --bg3: #181c22;
  --bg4: #1e232b;
  --border: #22272e;
  --border2: #2d343e;
  --text: #e8eaed;
  --text2: #aeb4bc;
  --text3: #7a828c;
  --green: #0ecb81;
  --red: #f6465d;
  --accent: #f0b90b;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  /* IMPORTANT: do NOT put height:100% + overflow-x:hidden on html.
     That combination kills vertical scrolling on many mobile browsers. */
}
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  min-height: 100dvh;          /* modern mobile viewport */
  min-height: 100%;            /* fallback */
  -webkit-font-smoothing: antialiased;
  /* extra room so last content clears the fixed bottom nav */
  padding-bottom: calc(72px + var(--safe-bottom));
  overflow-x: hidden;          /* only on body – stops sideways scroll without breaking vertical */
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

/* ========== TOP BAR ========== */
.topbar {
  background: #06080a;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text3);
}
.topbar-inner {
  padding: 0 14px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.live-dot {
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.sep { opacity: 0.4; }
.source-note { display: none; }

/* ========== HEADER ========== */
.header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  padding: 0 14px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo {
  display: flex;
  align-items: baseline;
  gap: 5px;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}
.logo-mark {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.nav { display: none; } /* moved to bottom on mobile */
.header-right { display: none; }

/* ========== BOTTOM NAV (phone primary) ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 0 0 var(--safe-bottom);
  height: calc(56px + var(--safe-bottom));
  /* prevent any bounce/scroll issues */
  touch-action: manipulation;
}
.bottom-nav button {
  flex: 1;
  background: none;
  border: none;
  color: var(--text3);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px; /* better touch target */
}
.bottom-nav button.active {
  color: var(--accent);
}
.bottom-nav .nav-icon {
  font-size: 18px;
  line-height: 1;
}

/* ========== SECTIONS ========== */
.section { display: none; padding-bottom: 8px; }
.section.active { display: block; }

/* ========== INDICES ========== */
.indices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
/*
  TILE BACKGROUND
  Put img.jpg next to styles.css (same folder).
  Path is relative to the CSS file, not the HTML.
*/
:root {
  --tile-bg: url('img.jpg');
  --tile-overlay: rgba(8, 10, 14, 0.55);
}
.index-card,
.fuel-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background-color: var(--bg2);
  background-image: var(--tile-bg) !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}
.index-card::before,
.fuel-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--tile-overlay);
  z-index: 0;
  pointer-events: none;
}
.index-card > *,
.fuel-card > * {
  position: relative;
  z-index: 1;
}
.index-card {
  padding: 12px 14px;
}
/* keep last card full-width only when odd count – looks intentional */
.index-card:last-child:nth-child(odd) {
  grid-column: span 2;
}
.index-name {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.index-price {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 500;
}
.index-chg {
  font-family: var(--mono);
  font-size: 12px;
  margin-top: 2px;
}
.up { color: var(--green); }
.down { color: var(--red); }

/* ========== CONTENT ========== */
.content {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.content.single { max-width: none; }
.col-main, .col-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ========== BLOCKS ========== */
.block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}
.block-head h2 {
  font-size: 13px;
  font-weight: 600;
}
.badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text3);
  background: var(--bg4);
  border: 1px solid var(--border);
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.badge.live {
  color: var(--green);
  background: rgba(14, 203, 129, 0.12);
  border-color: rgba(14, 203, 129, 0.3);
}

/* ========== TABLES → denser + scrollable on phone ========== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 0; /* allow shrink */
}
.data-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text3);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.data-table th.r,
.data-table td.r { text-align: right; }
.data-table td {
  padding: 10px 10px; /* slightly tighter for mobile density */
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:active { background: rgba(255,255,255,0.03); }

.sym {
  font-weight: 600;
  font-family: var(--mono);
  font-size: 12px;
}
.name {
  color: var(--text2);
  font-size: 12px;
  /* prevent long names from blowing layout */
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: bottom;
}
.price, .chg {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  white-space: nowrap;
}

/* ========== WATCHLIST ========== */
.watchlist { padding: 4px 0; }
.watch-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  gap: 10px;
  min-height: 48px;
}
.watch-item:active { background: rgba(255,255,255,0.03); }
.watch-left { display: flex; flex-direction: column; min-width: 0; }
.watch-right {
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
  flex-shrink: 0;
}

/* ========== FUEL ========== */
.fuel-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}
.fuel-card {
  padding: 16px 12px;
  text-align: center;
}
.fuel-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.fuel-price {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.fuel-unit {
  font-size: 12px;
  color: var(--text3);
  font-weight: 400;
}
.fuel-chg {
  font-family: var(--mono);
  font-size: 12px;
  margin-top: 6px;
}

/* ========== FOOD MOVERS ========== */
.movers {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
}
.mover {
  background: var(--bg2);
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
}
.mover-name { font-size: 14px; color: var(--text2); }
.mover-pct {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
}

/* ========== FOOTER ========== */
.footer {
  border-top: 1px solid var(--border);
  padding: 16px 14px;
  font-size: 12px;
  color: var(--text3);
  text-align: center;
}
.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ========== DESKTOP (min-width 768) ========== */
@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }
  .nav {
    display: flex;
    gap: 4px;
    flex: 1;
  }
  .nav-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text3);
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 500;
    padding: 7px 14px;
    border-radius: 4px;
    cursor: pointer;
  }
  .nav-btn:hover { color: var(--text); background: var(--bg3); }
  .nav-btn.active {
    color: var(--text);
    background: var(--bg3);
    border-color: var(--border2);
  }
  .header-right { display: block; margin-left: auto; }
  .tagline-desktop { font-size: 12px; color: var(--text3); }
  .source-note { display: inline; font-size: 11px; }

  .indices {
    grid-template-columns: repeat(5, 1fr);
  }
  .index-card:last-child:nth-child(odd) {
    grid-column: auto;
  }
  .content {
    max-width: 1440px;
    margin: 0 auto;
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 14px;
  }
  .content.single {
    grid-template-columns: 1fr;
    max-width: 960px;
  }
  .fuel-cards {
    grid-template-columns: repeat(4, 1fr);
  }
  .movers {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
  .footer-inner {
    max-width: 1440px;
    margin: 0 auto;
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
  .name {
    max-width: none;
  }
  .data-table td {
    padding: 11px 12px;
  }
}

/* Extra small phones (<360px) – squeeze tables a bit more */
@media (max-width: 360px) {
  .data-table {
    font-size: 12px;
  }
  .data-table th,
  .data-table td {
    padding: 8px 8px;
  }
  .index-price {
    font-size: 15px;
  }
  .fuel-price {
    font-size: 18px;
  }
}


/* ========== RESPONSIVE DENSITY ========== */
.desktop-only { display: none; }

@media (min-width: 768px) {
  .desktop-only { display: block; }
  .indices {
    grid-template-columns: repeat(6, 1fr);
  }
  .fuel-cards {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Phone: tight dashboard tiles */
@media (max-width: 767px) {
  .indices {
    grid-template-columns: 1fr 1fr;
  }
  .index-card {
    padding: 10px 12px;
  }
  .index-price {
    font-size: 15px;
  }
  .fuel-cards {
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
  }
  .fuel-card {
    border: none;
    border-radius: 0;
    padding: 12px;
  }
  .content {
    padding: 10px;
    gap: 10px;
  }
  .block {
    border-radius: 8px;
  }
  /* hide bulky tables on phone landing — cards + summary only */
  #section-trhy .table-wrap.desktop-only {
    display: none !important;
  }
}
