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

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --calories: #ef4444;
    --carbs: #f59e0b;
    --fat: #8b5cf6;
    --protein: #10b981;
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: 80px;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
}

/* Navigation */
.nav-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card);
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 12px;
    transition: color 0.2s;
}

.nav-item svg {
    width: 24px;
    height: 24px;
}

.nav-item.active {
    color: var(--primary);
}

/* Header */
.header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
}

.back-btn {
    color: var(--text);
    text-decoration: none;
}

.back-btn svg {
    width: 24px;
    height: 24px;
}

/* Progress Cards */
.progress-cards {
    margin-bottom: 24px;
}

.progress-card.calories {
    background: var(--card);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 16px;
}

.progress-ring {
    position: relative;
    width: 100px;
    height: 100px;
}

.progress-ring svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.progress-ring .bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 3;
}

.progress-ring .fill {
    fill: none;
    stroke: var(--calories);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dasharray 0.5s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.progress-text .value {
    display: block;
    font-size: 24px;
    font-weight: 700;
}

.progress-text .label {
    font-size: 12px;
    color: var(--text-muted);
}

.progress-info .title {
    display: block;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.progress-info .goal {
    color: var(--text-muted);
}

/* Macros Row */
.macros-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.macro-card {
    background: var(--card);
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
}

.macro-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 12px;
    overflow: hidden;
}

.macro-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.macro-card.carbs .macro-fill { background: var(--carbs); }
.macro-card.fat .macro-fill { background: var(--fat); }
.macro-card.protein .macro-fill { background: var(--protein); }

.macro-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
}

.macro-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin: 4px 0;
}

.macro-goal {
    font-size: 11px;
    color: var(--text-muted);
}

/* Food Form */
.add-food-section {
    margin-bottom: 24px;
}

.food-form {
    display: flex;
    gap: 12px;
}

.food-form input {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    color: var(--text);
    font-size: 16px;
}

.food-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.food-form input::placeholder {
    color: var(--text-muted);
}

.food-form button {
    background: var(--primary);
    border: none;
    border-radius: 12px;
    width: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.food-form button:hover {
    background: var(--primary-dark);
}

.food-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.food-form button svg {
    width: 24px;
    height: 24px;
    color: white;
}

/* Entries */
.entries-section h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.entries-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.entry-card {
    background: var(--card);
    border-radius: 12px;
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
}

.entry-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.entry-desc {
    font-weight: 500;
    line-height: 1.4;
}

.entry-time {
    font-size: 12px;
    color: var(--text-muted);
}

.entry-macros {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    grid-column: 1 / -1;
}

.entry-macros .cal {
    color: var(--calories);
    font-weight: 600;
}

.entry-macros .macro {
    color: var(--text-muted);
}

.delete-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    grid-row: 1;
    grid-column: 2;
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--calories);
}

.delete-btn svg {
    width: 20px;
    height: 20px;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 32px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 200;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* History */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-card {
    background: var(--card);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.2s;
}

.history-card:active {
    transform: scale(0.98);
}

.history-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 48px;
}

.history-date .day {
    font-size: 24px;
    font-weight: 700;
}

.history-date .month {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.history-info {
    flex: 1;
}

.history-cal .value {
    font-size: 20px;
    font-weight: 700;
}

.history-cal .unit {
    font-size: 14px;
    color: var(--text-muted);
}

.history-macros {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.mini-ring {
    width: 48px;
    height: 48px;
}

.mini-ring svg {
    transform: rotate(-90deg);
}

.mini-ring .bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 3;
}

.mini-ring .fill {
    fill: none;
    stroke: var(--primary);
    stroke-width: 3;
    stroke-linecap: round;
}

.mini-ring.over .fill {
    stroke: var(--calories);
}

/* Settings */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 32px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-group label {
    font-size: 14px;
    color: var(--text-muted);
}

.setting-group input {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    color: var(--text);
    font-size: 18px;
    font-weight: 600;
}

.setting-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.save-btn {
    background: var(--primary);
    border: none;
    border-radius: 12px;
    padding: 16px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.save-btn:hover {
    background: var(--primary-dark);
}

.info-card {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
}

.info-card h3 {
    font-size: 16px;
    margin-bottom: 16px;
}

.info-card ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-card li {
    color: var(--text-muted);
}

.info-card strong {
    color: var(--text);
}
