:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: #d1fae5;
    
    --bg-page: #f8fafc;
    --bg-panel: #ffffff;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --border: #e2e8f0;
    
    --color-protein: #f43f5e;
    --color-fat: #eab308;
    --color-carbs: #3b82f6;

    --status-under: #3b82f6;
    --status-normal: #10b981;
    --status-over: #f59e0b;
    --status-obese: #ef4444;

    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary-dark);
}

h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

/* UI Elements */
.toggle-group {
    display: flex;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
}

.toggle-group.full-width {
    width: 100%;
}

.toggle-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn:hover {
    color: var(--text-main);
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
}

.btn-primary, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: var(--bg-page);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #f1f5f9;
}

/* Layout */
main {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    flex: 1;
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--bg-panel);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.panel-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.profile-select {
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border);
    font-size: 0.875rem;
    background-color: var(--bg-page);
    cursor: pointer;
    outline: none;
}

/* Forms */
.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-row.flex-row {
    align-items: flex-end;
}

.flex-1 {
    flex: 1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group.full-width {
    margin-bottom: 1rem;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

.unit-label {
    color: var(--text-light);
    font-weight: 400;
}

input[type="number"], select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
    color: var(--text-main);
}

input[type="number"]:focus, select:focus {
    border-color: var(--primary);
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 1.5rem 0 1rem;
}

.section-label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.form-actions button {
    flex: 1;
}

.hidden {
    display: none !important;
}

/* Results Area */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state svg {
    color: var(--text-light);
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--text-main);
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.875rem;
    max-width: 300px;
}

/* Gauges */
.gauges-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 600px) {
    .gauges-container {
        grid-template-columns: 1fr;
    }
}

.gauge-card {
    background: var(--bg-page);
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 1px solid var(--border);
}

.gauge-card h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.gauge-wrapper {
    position: relative;
    width: 160px;
    height: 90px;
    display: flex;
    justify-content: center;
}

.gauge-value {
    position: absolute;
    bottom: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.gauge-label {
    margin-top: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    background: var(--border);
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--bg-page);
    border-radius: 0.75rem;
    padding: 1.25rem;
    border: 1px solid var(--border);
    text-align: center;
}

.metric-card.highlight {
    background: var(--primary-light);
    border-color: var(--primary);
}

.metric-card h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    letter-spacing: 0.025em;
}

.metric-card.highlight h4 {
    color: var(--primary-dark);
}

.metric-val {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.metric-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.metric-card.highlight .metric-desc {
    color: var(--primary-dark);
    font-weight: 500;
}

/* Macros */
.macros-section {
    background: var(--bg-page);
    border-radius: 0.75rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.macros-section h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.macro-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.macro-bars {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.macro-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.macro-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    font-weight: 600;
}

.macro-name.protein { color: var(--color-protein); }
.macro-name.fat { color: var(--color-fat); }
.macro-name.carbs { color: var(--color-carbs); }

.macro-bar-bg {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.macro-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease-out;
}

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

.macro-cals {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}

/* Footer */
footer {
    padding: 2rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
}

footer strong {
    color: var(--text-main);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 100;
}

.modal {
    background: var(--bg-panel);
    border-radius: 1rem;
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.modal h2 {
    margin-bottom: 0.5rem;
}

.modal p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.modal input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    outline: none;
}

.modal input:focus {
    border-color: var(--primary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}
