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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0a0a0a;
    color: #e0e0e0;
    padding: 10px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: #0a0a0a;
}

header {
    color: #fff;
    padding: 20px 0;
    margin-bottom: 20px;
}

header h1 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tab {
    background: #1a1a1a;
    border: 1px solid #333;
    padding: 8px 16px;
    color: #ccc;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.tab.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    padding: 20px;
    background: #111;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #222;
}

.stats .stat-card {
    background: #1a1a1a;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid #222;
}

.stats .stat-card.highlight {
    background: #1a0a2e;
    border: 2px solid #7c3aed;
}

.stats .stat-card.fat-loss {
    background: #0a2e1a;
    border: 2px solid #22c55e;
}

.stats .stat-card.fat-loss .value {
    color: #22c55e !important;
}

.stats .stat-card.fat-gain {
    background: #2e0a0a;
    border: 2px solid #ef4444;
}

.stats .stat-card.fat-gain .value {
    color: #ef4444 !important;
}

.stats .stat-card .label {
    display: block;
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.stats .stat-card.highlight .label {
    color: #a78bfa;
}

.stats .stat-card .value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: #f59e0b;
}

.stats .stat-card.highlight .value {
    font-size: 2.2rem;
}

.stats .stat-card .unit {
    display: block;
    font-size: 0.8rem;
    color: #666;
    margin-top: 4px;
}

.stats .stat-card.highlight .unit {
    color: #888;
}

.add-entry {
    padding: 20px;
    background: #111;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #222;
}

.add-entry h2 {
    margin-bottom: 15px;
    color: #fff;
    font-size: 1.2rem;
}

.form-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.toggle-btn {
    padding: 8px 16px;
    border: 1px solid #667eea;
    background: #1a1a1a;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.toggle-btn.active {
    background: #667eea;
    color: white;
}

.entry-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.entry-form input {
    padding: 10px;
    border: 1px solid #333;
    border-radius: 8px;
    font-size: 0.9rem;
    background: #1a1a1a;
    color: #e0e0e0;
}

.entry-form input:focus {
    outline: none;
    border-color: #667eea;
}

.entry-form button {
    grid-column: 1 / -1;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.entry-form button:hover {
    background: #5568d3;
}

.view-content {
    min-height: 200px;
}

/* Day cards (details/summary) */
.day {
    background: #111;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    border: 1px solid #222;
}

.day summary {
    cursor: pointer;
    list-style: none;
    user-select: none;
}

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

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.day-header h3 {
    font-size: 1.2rem;
    color: #fff;
}

.day-header h3::after {
    content: ' ▸';
    font-size: 1.2rem;
    color: #888;
    margin-left: 8px;
}

.day[open] .day-header h3::after {
    content: ' ▾';
}

.day-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.day-stats .stat {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 8px 12px;
    text-align: center;
    min-width: 60px;
    border: 1px solid #222;
}

.day-stats .stat .value {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.day-stats .stat .label {
    font-size: 0.65rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.day-stats .stat.kcal .value { color: #f59e0b; }
.day-stats .stat.protein .value { color: #22c55e; }
.day-stats .stat.carbs .value { color: #3b82f6; }
.day-stats .stat.fat .value { color: #ef4444; }
.day-stats .stat.net .value { color: #a78bfa; }
.day-stats .stat.fatloss .value { color: #22c55e; }
.day-stats .stat.fatgain .value { color: #ef4444; }

/* Day details (when expanded) */
.day-details {
    margin-top: 15px;
}

.meal-group {
    margin-bottom: 20px;
    padding-top: 15px;
    border-top: 1px solid #222;
}

.meal-header {
    font-size: 1rem;
    color: #ccc;
    margin-bottom: 10px;
    font-weight: 600;
}

.meal-header span {
    color: #888;
    font-weight: 400;
    font-size: 0.85rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead th {
    text-align: left;
    color: #666;
    font-weight: 500;
    padding: 8px;
    border-bottom: 1px solid #222;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody td {
    padding: 8px;
    border-bottom: 1px solid #1a1a1a;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr.total td {
    font-weight: 700;
    color: #fff;
    border-top: 1px solid #333;
    padding-top: 12px;
}

.delete-btn {
    padding: 4px 8px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
}

.delete-btn:hover {
    background: #dc2626;
}

/* Sport activities */
.sport-activity {
    margin-top: 15px;
    padding: 12px;
    background: #1a1a1a;
    border-radius: 8px;
    border: 1px solid #222;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sport-header {
    font-size: 0.95rem;
    color: #ccc;
    font-weight: 600;
}

.sport-header span {
    color: #888;
    font-weight: 400;
    font-size: 0.85rem;
}

/* Calorie balance bar */
.calorie-balance {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 15px;
    padding: 15px;
    background: #0d0d0d;
    border-radius: 10px;
    border: 1px solid #222;
    font-size: 0.9rem;
}

.cb-item {
    text-align: center;
    padding: 6px 10px;
}

.cb-value {
    font-size: 1.2rem;
    font-weight: 700;
}

.cb-label {
    font-size: 0.65rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.cb-eaten .cb-value { color: #f59e0b; }
.cb-sport .cb-value { color: #f97316; }
.cb-net .cb-value { color: #a78bfa; }
.cb-tdee .cb-value { color: #888; }
.cb-fat.loss .cb-value { color: #22c55e; }
.cb-fat.gain .cb-value { color: #ef4444; }

.cb-fat {
    background: #1a0a2e;
    border: 1px solid #7c3aed44;
    border-radius: 8px;
    padding: 8px 12px;
}

.cb-op, .cb-eq {
    color: #555;
    font-size: 1.2rem;
    font-weight: 300;
}

/* Macro bar */
.macro-section {
    margin-top: 15px;
}

.macro-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
}

.macro-bar .macro-protein { background: #22c55e; }
.macro-bar .macro-carbs { background: #3b82f6; }
.macro-bar .macro-fat { background: #ef4444; }

.macro-legend {
    display: flex;
    gap: 15px;
    margin-top: 8px;
    font-size: 0.75rem;
    color: #888;
}

.macro-legend span::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

.macro-legend .protein::before { background: #22c55e; }
.macro-legend .carbs::before { background: #3b82f6; }
.macro-legend .fat::before { background: #ef4444; }

/* Settings form */
.settings-form {
    max-width: 600px;
    background: #111;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #222;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    font-weight: 600;
    color: #ccc;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.setting-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #333;
    border-radius: 8px;
    font-size: 0.9rem;
    background: #1a1a1a;
    color: #e0e0e0;
}

.setting-group input:focus {
    outline: none;
    border-color: #667eea;
}

.setting-group small {
    display: block;
    color: #666;
    margin-top: 5px;
    font-size: 0.8rem;
}

.settings-form button {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}

.settings-form button:hover {
    background: #5568d3;
}

/* Weekly view */
.week-card {
    background: #111;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #222;
}

.week-card h3 {
    font-size: 1.2rem;
    color: #fff;
    margin-bottom: 15px;
}

.week-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.week-stat {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    border: 1px solid #222;
}

.ws-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f59e0b;
}

.ws-label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

.week-days {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.week-day-item {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    border: 1px solid #222;
}

.wd-header {
    font-size: 0.85rem;
    color: #ccc;
    font-weight: 600;
    margin-bottom: 6px;
}

.wd-kcal {
    font-size: 1rem;
    color: #a78bfa;
    margin-bottom: 4px;
}

.wd-fat {
    font-size: 0.85rem;
    font-weight: 600;
}

.wd-fat.loss {
    color: #22c55e;
}

.wd-fat.gain {
    color: #ef4444;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        padding: 8px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .tabs {
        gap: 5px;
    }
    
    .tab {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    .stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 15px;
    }
    
    .stats .stat-card {
        padding: 12px;
    }
    
    .stats .stat-card .value {
        font-size: 1.3rem;
    }
    
    .stats .stat-card.highlight .value {
        font-size: 1.6rem;
    }
    
    .stats .stat-card.highlight .label {
        font-size: 0.75rem;
    }
    
    .add-entry {
        padding: 15px;
    }
    
    .entry-form {
        grid-template-columns: 1fr;
    }
    
    .day {
        padding: 15px;
    }
    
    .day-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .day-header h3 {
        font-size: 1.1rem;
    }
    
    .day-stats {
        width: 100%;
        justify-content: space-between;
    }
    
    .day-stats .stat {
        flex: 1;
        min-width: 55px;
        padding: 6px 8px;
    }
    
    .day-stats .stat .value {
        font-size: 0.9rem;
    }
    
    .day-stats .stat .label {
        font-size: 0.6rem;
    }
    
    table {
        font-size: 0.75rem;
    }
    
    thead th, tbody td {
        padding: 6px 4px;
    }
    
    .calorie-balance {
        padding: 12px;
        gap: 6px;
    }
    
    .cb-item {
        padding: 4px 8px;
    }
    
    .cb-value {
        font-size: 1rem;
    }
    
    .cb-label {
        font-size: 0.6rem;
    }
    
    .sport-activity {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .delete-btn {
        align-self: flex-end;
        width: 100%;
    }
    
    .week-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .week-days {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .ws-value {
        font-size: 1.2rem;
    }
}
