@import url('https://fonts.googleapis.com/css2?family=Racing+Sans+One&display=swap');

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f4f9;
    color: #333;
    margin: 0;
    padding-top: 70px;
    padding-bottom: 20px;
    padding-left: 10px;
    padding-right: 10px;
    transition: background 0.5s ease;
}

/* --- CHAMPION THEME --- */
body.champion-bg {
    background: linear-gradient(135deg, #f4f4f9 0%, #fff8e1 100%);
}

.champion-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    margin-bottom: 20px;
    animation: popIn 0.8s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.champion-shield {
    position: relative;
    background: linear-gradient(to bottom, #d4af37, #b8860b); /* Gold gradient */
    padding: 10px 25px 25px 25px; /* Extra bottom padding for shape */
    border-radius: 8px 8px 50% 50%; /* Shield Shape */
    box-shadow: 0 5px 15px rgba(218, 165, 32, 0.4);
    text-align: center;
    border: 2px solid #fff;
}

.deficit-plaquette {
    background: #2c3e50;
    color: #ffd700;
    font-family: 'Racing Sans One', cursive;
    font-size: 11px;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 4px;
    margin-bottom: 5px;
    display: inline-block;
    letter-spacing: 1px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

@keyframes popIn { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.container { max-width: 900px; margin: 0 auto; }

h1, h2, .stat-number {
    font-family: 'Racing Sans One', cursive; 
    font-weight: 400; 
    letter-spacing: 1px;
    color: #2c3e50;
}
/* For champion header text override */
.champion-shield h1 {
    margin: 5px 0 0 0;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* FIXED HEADER */
.fixed-header {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 60px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    box-shadow: 0 1px 5px rgba(0,0,0,0.1);
    z-index: 9999;
    display: flex; justify-content: center;
    padding: 0 10px;
}
.header-inner {
    width: 100%; max-width: 900px;
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.header-btn {
    display: flex; align-items: center; justify-content: center;
    height: 34px; padding: 0 15px; border-radius: 17px;
    background-color: transparent !important;
    border: 1px solid #ccc !important;
    color: #555 !important;
    font-family: sans-serif; font-size: 13px; text-decoration: none !important;
    cursor: pointer; transition: all 0.2s ease; white-space: nowrap;
}
.header-btn svg { width: 14px; height: 14px; margin-right: 6px; fill: #555; }

.last-fetch-indicator {
    font-size: 11px;
    color: #999;
    font-family: sans-serif;
    margin-right: auto; /* Pushes buttons to right if flex container allows, but here it works with space-between */
}

.header-title-row { margin-bottom: 20px; text-align: center; margin-top: 10px; }

.card {
    background: white; padding: 20px; border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); margin-bottom: 20px;
}
.login-box { text-align: center; margin-top: 50px; }
input[type="text"] { padding: 10px; font-size: 16px; border: 1px solid #ddd; border-radius: 4px; }
.btn-start {
    padding: 10px 20px; font-size: 16px; background-color: #28a745;
    color: white; border: none; border-radius: 4px; cursor: pointer; margin-left: 5px;
}
.btn-start:hover { background-color: #218838; }

table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid #ddd; }
th { background-color: #f8f9fa; font-weight: 600; font-family: sans-serif; }
.negative { color: #d9534f; font-weight: bold; } 
.positive { color: #28a745; font-weight: bold; } 

/* STAT GRID & FLIP CARDS */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 20px; }

.flip-container { perspective: 1000px; height: 100px; cursor: pointer; }
.flipper { transition: 0.6s; transform-style: preserve-3d; position: relative; width: 100%; height: 100%; }
.flip-container.flipped .flipper { transform: rotateY(180deg); }

.front, .back {
    backface-visibility: hidden;
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    background: #fff;
    padding: 15px;
    display: flex; flex-direction: column; align-items: center;
}
.front { justify-content: center; }
.back {
    transform: rotateY(180deg);
    background: #fdfdfd;
    justify-content: flex-start;
    align-items: stretch;
    overflow-y: auto;
    padding-top: 12px;
}
.back strong {
    display: block; margin-bottom: 8px; text-align: center;
    color: #2c3e50; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
    flex-shrink: 0;
}

.ranking-table { width: 100%; font-size: 11px; border-collapse: collapse; }
.ranking-table td { padding: 4px 0; border-bottom: 1px solid #eee; }
.ranking-table tr:last-child td { border-bottom: none; }
.rank-pos { font-weight: bold; color: #999; width: 20px; }
.rank-val { text-align: right; font-weight: bold; }
.rank-name { padding-left: 5px; }
.back::-webkit-scrollbar { width: 4px; }
.back::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* DARK TILE FIXES */
.year-stats { background: #2c3e50; color: white; }
.year-stats .stat-number { color: #f4f4f9; }
.year-stats .stat-label { color: #ccc; }

.year-stats.back, .streak-fire.back { color: white; }
.year-stats.back strong, .streak-fire.back strong { color: #fff; border-bottom: 1px solid rgba(255,255,255,0.2); padding-bottom: 4px; }
.year-stats.back .ranking-table td, .streak-fire.back .ranking-table td { border-bottom: 1px solid rgba(255,255,255,0.1); }
.year-stats.back .rank-pos, .streak-fire.back .rank-pos { color: rgba(255,255,255,0.6); }

/* FIRE STREAK */
.streak-fire {
    background: linear-gradient(135deg, #ff3c00 10%, #ff9d00 100%) !important; 
    color: white !important;
    box-shadow: 0 0 15px rgba(255, 69, 0, 0.6), inset 0 0 10px rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 69, 0, 0.8) !important;
}
.streak-fire .stat-number, .streak-fire .stat-label { color: white !important; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }

/* STAT BOX DEFAULTS */
.stat-number { font-size: 28px; display: block; color: #2c3e50; text-align: center; }
.stat-label { font-size: 12px; color: #888; text-transform: uppercase; letter-spacing: 1px; margin-top: 5px; font-family: sans-serif; text-align: center; }

@media (max-width: 600px) { .stat-grid { grid-template-columns: 1fr; } }
.chart-container { position: relative; height: 450px; width: 100%; }
.chart-controls { text-align: right; margin-bottom: 10px; }
.toggle-btn { background: #e9ecef; border: none; padding: 5px 12px; border-radius: 20px; font-size: 13px; cursor: pointer; margin-left: 5px; }
.toggle-btn.active { background: #2c3e50; color: white; }

.netto-glow-green { background: linear-gradient(135deg, rgba(40, 167, 69, 0.2) 0%, rgba(40, 167, 69, 0.5) 100%) !important; box-shadow: 0 0 15px rgba(40, 167, 69, 0.6), inset 0 0 10px rgba(255, 255, 255, 0.3); border: 1px solid rgba(40, 167, 69, 0.8) !important; }
.netto-glow-green .stat-number { color: #1e7e34; text-shadow: 0 0 5px rgba(40, 167, 69, 0.3); }
.netto-glow-green .stat-label { color: #155724; font-weight: bold; }

.netto-glow-magenta { background: linear-gradient(135deg, rgba(255, 0, 255, 0.1) 0%, rgba(255, 0, 255, 0.3) 100%) !important; box-shadow: 0 0 15px rgba(255, 0, 255, 0.5), inset 0 0 10px rgba(255, 255, 255, 0.3); border: 1px solid rgba(255, 0, 255, 0.7) !important; }
.netto-glow-magenta .stat-number { color: #c000c0; text-shadow: 0 0 5px rgba(255, 0, 255, 0.3); }
.netto-glow-magenta .stat-label { color: #800080; font-weight: bold; }

.nutrient-row { margin-bottom: 15px; }
.nutrient-label { display: flex; justify-content: space-between; font-size: 13px; color: #555; margin-bottom: 5px; font-family: sans-serif; }
.nutrient-bar-bg { width: 100%; height: 12px; background: #eee; border-radius: 6px; overflow: hidden; position: relative; border: 1px solid #ddd; }
.nutrient-bar-fill { height: 100%; border-radius: 6px; transition: width 0.5s ease-out; }
.bar-low { background-color: #f1c40f; } .bar-ok { background-color: #2ecc71; } .bar-high { background-color: #e056fd; } 
.marker-line { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(0,0,0,0.4); z-index: 2; }

#loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #f4f4f9; z-index: 10000; display: flex; justify-content: center; align-items: center; }
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
.spinner { width: 50px; height: 50px; border: 5px solid #ddd; border-top: 5px solid #2c3e50; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* SLIDERS */
.override-list { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; }
.override-item { background: #fff; padding: 10px; border-radius: 8px; border: 1px solid #eee; text-align: center; min-width: 80px; }
.override-date { display: block; font-size: 12px; margin-bottom: 8px; font-weight: bold; }

.switch { position: relative; display: inline-block; width: 34px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }

input:checked + .slider:before { transform: translateX(14px); }

/* States */
.slider-red { background-color: #ff4d4d; }
input:checked + .slider-green { background-color: #2ecc71; }
.slider-grey { background-color: #bdc3c7; cursor: not-allowed; }