:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.8);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-color: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.4);
    --border-color: rgba(255, 255, 255, 0.08);
    --up-color: #22c55e;
    --down-color: #ef4444;
    --nav-height: 56px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.2) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.2) 0, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
}

/* ══════════════════════════════════════════════
   NAV
══════════════════════════════════════════════ */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    height: var(--nav-height);
}

.nav-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-logo {
    font-weight: 800;
    font-size: 1rem;
    color: var(--text-main);
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: -0.02em;
    margin-right: 8px;
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    gap: 2px;
    flex: 1;
    flex-wrap: nowrap;
    overflow: hidden;
    align-items: center;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    transition: color 0.2s, background 0.2s;
}

.nav-link:hover {
    color: var(--text-main);
    background: rgba(255,255,255,0.06);
}

.nav-link.active {
    color: var(--accent-color);
    background: rgba(56,189,248,0.1);
}

/* Hamburger */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    margin-left: auto;
}

.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-muted);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile dropdown */
.mobile-menu {
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.98);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    z-index: 99;
}

.mobile-menu.hidden { display: none; }

.mobile-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 12px 24px;
    transition: background 0.2s, color 0.2s;
}

.mobile-link:hover { background: rgba(255,255,255,0.04); color: var(--text-main); }
.mobile-link.active { color: var(--accent-color); }

@media (max-width: 700px) {
    .nav-links      { display: none; }
    .hamburger-btn  { display: flex; }
}

/* ══════════════════════════════════════════════
   CHART PAGE LAYOUT
══════════════════════════════════════════════ */
.page-body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 30px 20px;
    min-height: calc(100vh - var(--nav-height));
}

.container {
    width: 100%;
    max-width: 900px;
}

.glassmorphism {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

/* ── Header ── */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

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

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(16, 185, 129, 0.1);
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.dot {
    width: 7px;
    height: 7px;
    background-color: #10b981;
    border-radius: 50%;
    flex-shrink: 0;
}

.pulse { animation: pulse-animation 2s infinite; }

@keyframes pulse-animation {
    0%   { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16,185,129,0.7); }
    70%  { transform: scale(1);    box-shadow: 0 0 0 6px rgba(16,185,129,0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

.status-text {
    color: #10b981;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-muted);
}

.ig-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
.ig-link-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: translateY(-1px);
}
.ig-link-btn svg {
    width: 16px;
    height: 16px;
}

/* ── Price row ── */
.data-display {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    min-height: 70px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.price-container {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    animation: fadeIn 0.5s ease-out;
}

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

.price-value {
    font-size: 3.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, #e2e8f0, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.price-change {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-bottom: 6px;
}

.change-val, .change-pct {
    font-size: 1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 3px 8px;
    border-radius: 6px;
}

.change-val.up, .change-pct.up { color: var(--up-color);   background: rgba(34,197,94,0.12); }
.change-val.down, .change-pct.down { color: var(--down-color); background: rgba(239,68,68,0.12); }

/* ── Chart ── */
.chart-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.chart-tab {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.chart-tab.active {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
    color: var(--accent-color);
}

.chart-wrapper {
    width: 100%;
    height: 320px;
    margin-bottom: 24px;
    position: relative;
    touch-action: pan-y;
}

.tv-wrapper {
    width: 100%;
    height: 420px;
    margin-bottom: 24px;
    background: #fff; /* TV widget is light theme */
    border-radius: 8px;
    overflow: hidden;
}

/* ── Crosshair tooltip ── */
#crosshair-tooltip {
    display: none;
    position: absolute;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 6px 12px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 10;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    font-size: 0.85rem;
    line-height: 1.4;
}

.ch-date  { color: #94a3b8; margin-right: 6px; }
.ch-price { color: #f8fafc; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Footer ── */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 18px;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-info { display: flex; flex-direction: column; gap: 3px; }
.footer-info p { color: var(--text-muted); font-size: 0.82rem; }
.fetch-time    { font-size: 0.74rem !important; opacity: 0.65; }
#server-updated, #last-updated { color: var(--text-main); font-weight: 600; font-variant-numeric: tabular-nums; }

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.refresh-btn:hover  { background: rgba(255,255,255,0.06); border-color: var(--accent-color); color: var(--accent-color); }
.refresh-btn:active { transform: scale(0.95); }
.refresh-btn.spinning svg { animation: spin 1s linear infinite; }

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

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,0.08);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s ease-in-out infinite;
}

.hidden { display: none !important; }

.value-changed { animation: highlight 0.8s ease-out; }

@keyframes highlight {
    0%   { opacity: 1; }
    30%  { opacity: 0.5; }
    100% { opacity: 1; }
}

/* ══════════════════════════════════════════════
   LANDING PAGE
══════════════════════════════════════════════ */
.landing-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px 60px;
    min-height: calc(100vh - var(--nav-height));
}

.landing-header {
    text-align: center;
    margin-bottom: 40px;
}

.landing-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.landing-header p {
    color: var(--text-muted);
    font-size: 1rem;
}

.instrument-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    width: 100%;
    max-width: 900px;
}

.instrument-card {
    text-decoration: none;
    display: block;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 22px 24px;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.instrument-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.5), 0 0 0 1px rgba(56,189,248,0.3);
    border-color: rgba(56,189,248,0.3);
}

.card-instrument-name {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}

.card-price {
    font-size: 1.8rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
    letter-spacing: -0.02em;
    margin-bottom: 6px;
    min-height: 2rem;
}

.card-change {
    font-size: 0.85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.card-change.up   { color: var(--up-color); }
.card-change.down { color: var(--down-color); }

.card-live-dot {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 12px;
    color: #10b981;
    font-size: 0.75rem;
    font-weight: 600;
}

.card-live-dot .dot { background: #10b981; width: 6px; height: 6px; }

@media (max-width: 500px) {
    .landing-header h1 { font-size: 1.6rem; }
    .instrument-grid   { grid-template-columns: 1fr 1fr; gap: 10px; }
    .instrument-card   { padding: 16px; }
    .card-price        { font-size: 1.4rem; }
}

/* ── Footer ── */
.site-footer {
    text-align: center;
    padding: 40px 20px 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.site-footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}
.site-footer a:hover {
    color: var(--text-main);
    text-decoration: underline;
}
