:root {
    --bg:          #0d0d0d;
    --card-bg:     #1a1a2e;
    --card-border: #2a2a4a;
    --text:        #e0e0e0;
    --text-dim:    #bbb;
    --muted:       #888;
    --muted-dark:  #555;
    --positive:    #00c853;
    --negative:    #f44336;
    --accent:      #f7931a;
    --accent-text: #000;
    --radius:      8px;
    --radius-sm:   4px;
    --radius-lg:   20px;
    --transition:  0.15s;
}

[data-theme="light"] {
    --bg:          #f0f2f5;
    --card-bg:     #ffffff;
    --card-border: #e0e0e0;
    --text:        #1a1a1a;
    --text-dim:    #444;
    --muted:       #666;
    --muted-dark:  #999;
    --positive:    #00a843;
    --negative:    #d32f2f;
    --accent:      #f7931a;
    --accent-text: #000;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    transition: background-color 0.25s, color 0.25s;
}

.card, .chart-box, .period-selector, .glossary-item, .currency-toggle, .lang-toggle, footer {
    transition: background-color 0.25s, border-color 0.25s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

/* ── Header ──────────────────────────────────────── */

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 28px;
}

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

.coin-icon {
    font-size: 2.6rem;
    color: var(--accent);
    line-height: 1;
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-text .ticker {
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 500;
}

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

.update-label {
    font-size: 0.78rem;
    color: var(--muted);
}

.coin-selector {
    display: flex;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.coin-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 6px 14px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: background var(--transition), color var(--transition);
}

.coin-btn.active { background: var(--accent); color: var(--accent-text); }
.coin-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.currency-toggle {
    display: flex;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.currency-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 6px 16px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: background var(--transition), color var(--transition);
}

.currency-btn.active { background: var(--accent); color: var(--accent-text); }
.currency-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.lang-toggle {
    display: flex;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: background var(--transition), color var(--transition);
}

.lang-btn.active { background: var(--accent); color: var(--accent-text); }
.lang-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ── Theme toggle ────────────────────────────────── */

#theme-toggle {
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: border-color var(--transition), background var(--transition);
}

#theme-toggle:hover { border-color: var(--accent); }
#theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Loading ─────────────────────────────────────── */

#loading {
    display: none;
    text-align: center;
    color: var(--muted);
    font-size: 0.88rem;
    padding: 10px;
    margin-bottom: 8px;
}

/* ── Cards base ──────────────────────────────────── */

.cards-grid {
    display: grid;
    gap: 10px;
    margin-bottom: 10px;
}

.main-cards      { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.secondary-cards { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 18px; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.price-card { border-color: var(--accent); }

.card-label {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 500;
}

.card-value {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.4px;
}

.card-value.accent   { color: var(--accent); font-size: 1.35rem; }
.card-value.positive { color: var(--positive); }
.card-value.negative { color: var(--negative); }

.card-sublabel { font-size: 0.65rem; color: var(--muted); margin-top: 2px; }

/* ── Advanced indicators ─────────────────────────── */

.advanced-cards {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    margin-top: 14px;
    margin-bottom: 28px;
}

.adv-card {
    gap: 6px;
}

/* Fear & Greed */

.fg-display {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: 2px;
}

.fg-num {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
}

.fg-class {
    font-size: 0.85rem;
    font-weight: 600;
}

.fg-bar-track {
    position: relative;
    height: 7px;
    border-radius: var(--radius-sm);
    background: linear-gradient(to right, #f44336 0%, #ff7043 22%, #888 45%, #69f0ae 72%, #00c853 100%);
    margin-top: 6px;
}

.fg-needle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 15px;
    background: #fff;
    border-radius: 2px;
    box-shadow: 0 0 5px rgba(0,0,0,0.7);
    transition: left 0.4s ease;
}

[data-theme="light"] .fg-needle { background: #333; }

.fg-axis-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--muted);
    margin-top: 4px;
}

/* Mayer Multiple */

.mayer-display {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
}

.mayer-value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-lg);
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge.sub  { background: rgba(0,200,83,0.12);    color: var(--positive); }
.badge.norm { background: rgba(136,136,136,0.12);  color: var(--muted); }
.badge.hot  { background: rgba(244,67,54,0.12);    color: var(--negative); }

/* Dominância */

.dom-value { font-size: 2rem; margin-top: 2px; }

/* Halving Countdown */

.halving-display { margin-top: 2px; }

.halving-days {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1;
    color: var(--accent);
}

/* MVRV */

.mvrv-card { justify-content: space-between; }

.mvrv-note {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.5;
}

.mvrv-link {
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    padding: 4px 0;
    display: inline-block;
}

.mvrv-link:hover { text-decoration: underline; }

.adv-sub {
    font-size: 0.72rem;
    color: var(--muted);
}

/* ── Period selector ─────────────────────────────── */

.period-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    margin-bottom: 14px;
}

.period-buttons {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.period-btn {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--muted);
    padding: 5px 11px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.period-btn:hover           { border-color: var(--accent); color: var(--accent); }
.period-btn.active          { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.period-btn:disabled        { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.period-btn:focus-visible   { outline: 2px solid var(--accent); outline-offset: 2px; }

.date-range {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
}

.date-range label {
    font-size: 0.78rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-range input[type="date"] {
    background: var(--bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 4px 8px;
    font-size: 0.78rem;
    outline: none;
    transition: border-color var(--transition);
}

.date-range input[type="date"]:focus         { border-color: var(--accent); }
.date-range input[type="date"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.date-range input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.5); cursor: pointer; }
[data-theme="light"] .date-range input[type="date"]::-webkit-calendar-picker-indicator { filter: none; opacity: 0.6; }

#btn-apply-dates {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 5px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: background var(--transition), color var(--transition);
}

#btn-apply-dates:hover        { background: var(--accent); color: var(--accent-text); }
#btn-apply-dates:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Chart ───────────────────────────────────────── */

.chart-box {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 28px;
}

.main-chart-box {
    height: 360px;
    position: relative;
}

.chart-note {
    display: block;
    text-align: right;
    font-size: 0.68rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.main-chart-box canvas { width: 100% !important; height: 100% !important; }

/* ── Glossary ────────────────────────────────────── */

.section-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 10px;
}

.glossary-item {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    overflow: hidden;
}

.glossary-item summary {
    padding: 14px 16px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}

.glossary-item summary::-webkit-details-marker { display: none; }

.glossary-item summary::before {
    content: '▶';
    font-size: 0.6rem;
    color: var(--accent);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.glossary-item[open] summary::before { transform: rotate(90deg); }

.glossary-body {
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.glossary-body p {
    font-size: 0.84rem;
    line-height: 1.65;
    color: var(--text-dim);
}

.glossary-body a { color: var(--accent); text-decoration: none; }
.glossary-body a:hover { text-decoration: underline; }

/* Fear & Greed scale in glossary */

.fg-scale {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.scale-item {
    padding: 3px 10px;
    border-radius: var(--radius-lg);
    font-size: 0.7rem;
    font-weight: 700;
}

.fear-extreme  { background: rgba(244,67,54,0.12);  color: #f44336; }
.fear          { background: rgba(255,112,67,0.12);  color: #ff7043; }
.neutral       { background: rgba(136,136,136,0.12); color: #aaa; }
.greed         { background: rgba(105,240,174,0.12); color: #69f0ae; }
.greed-extreme { background: rgba(0,200,83,0.12);    color: var(--positive); }

/* ── Footer ──────────────────────────────────────── */

footer {
    border-top: 1px solid var(--card-border);
    margin-top: 40px;
    padding-top: 28px;
    padding-bottom: 24px;
}

.disclaimer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

.disclaimer p {
    font-size: 0.74rem;
    color: var(--muted);
    line-height: 1.65;
    margin-bottom: 8px;
}

.copyright {
    font-size: 0.7rem;
    color: var(--muted-dark);
    margin-top: 14px;
}

/* ── BTC Valuation Charts ────────────────────────── */

#btc-valuation {
    margin-bottom: 32px;
}

.btc-val-intro {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 16px;
    line-height: 1.6;
}

.btc-val-loading {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 32px 0;
}

.btc-val-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.btc-val-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 20px;
}

.btc-val-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.btc-val-legend {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-bottom: 14px;
    line-height: 1.5;
}

.btc-val-chart-wrap {
    position: relative;
    height: 380px;
    margin-bottom: 12px;
}

.btc-val-disclaimer {
    font-size: 0.72rem;
    color: var(--muted-dark);
    line-height: 1.5;
    border-top: 1px solid var(--card-border);
    padding-top: 10px;
    margin-top: 4px;
}

/* ── Responsive ──────────────────────────────────── */

@media (max-width: 960px) {
    .advanced-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .advanced-cards    { grid-template-columns: repeat(2, 1fr); }
    .main-chart-box    { height: 300px; }
    .header-right      { gap: 10px; }
    .period-selector   { gap: 8px; }
    .btc-val-chart-wrap { height: 280px; }
}

@media (max-width: 640px) {
    .advanced-cards { grid-template-columns: 1fr; }
    .date-range     { margin-left: 0; width: 100%; }
    .header-right   { gap: 8px; }
    .main-chart-box { height: 280px; }
}
