:root {
    --bg-color: #f5f7fb;
    --card-bg: rgba(255, 255, 255, 0.85);
    --primary: #818cf8;
    --primary-light: #e0e7ff;
    --primary-glow: rgba(129, 140, 248, 0.2);
    --accent: #f472b6;
    --success: #34d399;
    --text-main: #1e293b;
    --text-dim: #64748b;
    --glass-border: rgba(255, 255, 255, 1);
    --radius-lg: 32px;
    --radius-md: 20px;
    --shadow-premium: 0 10px 30px -5px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --header-gradient: linear-gradient(135deg, #c3dafe 0%, #ecd4fc 100%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
}

.app-wrapper {
    position: relative;
    min-height: 100vh;
}

.header-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 300px;
    background: var(--header-gradient);
    z-index: 0;
}

.app-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
    padding-bottom: 100px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-top: env(safe-area-inset-top, 10px);
}

.header-content {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#header-time {
    font-size: 16px;
    font-weight: 700;
}

#header-date {
    font-size: 14px;
    font-weight: 600;
}

.balance-section {
    padding: 24px 0;
    margin-bottom: 24px;
}

.balance-section .label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 8px;
    display: block;
}

.balance-section .value {
    font-size: 48px;
    font-weight: 700;
    display: inline-block;
}

.balance-section .unit {
    font-size: 16px;
    color: var(--text-dim);
    margin-left: 8px;
}

.scroll-stats {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 8px 4px 24px;
    margin: 0 -20px;
    padding-left: 20px;
    padding-right: 20px;
}

.scroll-stats::-webkit-scrollbar {
    display: none;
}

.stat-card {
    min-width: 140px;
    padding: 20px !important;
    margin-bottom: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.pulse-icon { background: #e0e7ff; }
.cals-icon { background: #fee2e2; }
.bmi-icon { background: #fef3c7; }

.stat-card .label {
    font-size: 12px;
    letter-spacing: 0;
    margin-bottom: 0;
}

.stat-card .value {
    font-size: 24px;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-premium);
    overflow: hidden;
    transition: transform 0.2s ease;
}

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

.card.collapsed .card-content {
    display: none;
}

.card.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.toggle-trigger {
    cursor: pointer;
}

.toggle-icon {
    font-size: 18px;
    color: var(--text-dim);
    transition: transform 0.3s ease;
    display: inline-block;
}

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

.summary-card .stat-group {
    display: flex;
    gap: 32px;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

@media (min-width: 480px) {
    .stat-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.pill-btn {
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.nutrition-card {
    background: white;
}

.calorie-progress {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #818cf8);
    transition: width 0.5s ease-out;
}

.calorie-text {
    font-size: 18px;
    font-weight: 700;
}

.calorie-text small {
    font-weight: 400;
    color: var(--text-dim);
}

.food-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 150px;
    overflow-y: auto;
    padding-right: 4px;
}

.food-list::-webkit-scrollbar {
    width: 4px;
}

.food-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 2px;
}

.food-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    font-size: 14px;
}

.food-item .cals {
    color: var(--primary);
    font-weight: 600;
}

/* BMI Card */
.bmi-card {
    background: white;
}

.bmi-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.bmi-result-box {
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    text-align: center;
    border-left: 4px solid var(--primary);
}

.bmi-value-group {
    display: flex;
    flex-direction: column;
}

.bmi-value-group .value {
    font-size: 28px;
    line-height: 1;
    margin-bottom: 4px;
}

.status-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dim);
}

/* SCORE Card */
.score-card {
    background: white;
}

.section-desc {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 16px;
}

.score-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.score-result-box {
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    text-align: center;
    border-left: 4px solid var(--primary);
}

.score-value-group .value {
    font-size: 28px;
    display: block;
    margin-bottom: 4px;
}

/* Walk Card */
.walk-card {
    background: white;
}

.walk-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.walk-result-box {
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    text-align: center;
    border-left: 4px solid #10b981;
}

.walk-value-group .value {
    font-size: 28px;
    display: block;
    line-height: 1;
    color: #10b981;
}

.walk-value-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.res-main {
    text-align: left;
}

.walk-chart-container {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.walk-chart-container h4 {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 16px;
    font-weight: 600;
}

.walk-chart {
    height: 200px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 24px;
    padding-top: 30px;
}

.chart-bar-group {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

.chart-bar {
    width: 100%;
    background: var(--primary);
    border-radius: 12px 12px 0 0;
    min-height: 4px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    opacity: 0.7;
}

.chart-bar:hover {
    opacity: 1;
    transform: scaleX(1.1);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.chart-bar::after {
    content: attr(data-value);
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 6px;
    border-radius: 6px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    white-space: nowrap;
}

.chart-bar:hover::after {
    opacity: 1;
}

/* Show labels if there's enough room or just always for better UX */
.chart-bar[data-value]:not([data-value=""])::after {
    opacity: 1;
    top: -20px;
}

.chart-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    margin-top: 8px;
    text-transform: capitalize;
}

.food-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: #f8fafc;
    border: 1px solid rgba(0, 0, 0, 0.03);
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.history-info .date {
    font-size: 12px;
    color: var(--text-dim);
    display: block;
}

.history-info .values {
    font-size: 18px;
    font-weight: 600;
}

.history-pulse {
    text-align: right;
}

.pulse-val {
    font-weight: 600;
    color: var(--accent);
}

/* Overlay & Modal */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

.dashboard-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 32px;
}

.action-item {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    background: white;
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow-premium);
    transition: all 0.2s;
}

.action-item:active {
    transform: scale(0.9);
}

.action-item.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.main-fab {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #1e293b;
    border: none;
    color: white;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.main-fab:active {
    transform: scale(0.9);
}

.modal {
    background: white;
    width: 90%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--glass-border);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

input, select {
    width: 100%;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 14px;
    color: var(--text-main);
    font-size: 16px;
    outline: none;
    transition: all 0.2s;
}

input:focus, select:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.close-btn {
    background: #f1f5f9;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.pulse-field, .activity-field, .food-select-field {
    grid-column: span 2;
}

.input-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-dim);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
}

.settings-content h4 {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.setting-item:hover {
    background: #f1f5f9;
}

.setting-item input[type="checkbox"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: var(--primary);
}

.submit-btn:active {
    transform: scale(0.96);
}

.overlay:not(.hidden) .modal {
    transform: translateY(0);
}

.analysis-card {
    background: white;
    border-left: 6px solid var(--primary);
}

.status-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 800;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-normal { background: #dcfce7; color: #166534; }
.status-elevated { background: #fef9c3; color: #854d0e; }
.status-stage1 { background: #ffedd5; color: #9a3412; }
.status-stage2 { background: #fee2e2; color: #991b1b; }
.status-crisis { background: #7f1d1d; color: white; animation: pulse-red 2s infinite; }

.history-item {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-md);
    padding: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.pulse-val {
    font-weight: 700;
    color: var(--accent);
    font-size: 20px;
}

.activity-tag {
    background: #f1f5f9;
    color: #64748b;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 8px;
    font-weight: 600;
}

@keyframes pulse-red {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(127, 29, 29, 0.4); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(127, 29, 29, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(127, 29, 29, 0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}
