:root{
    --bg:#eef3f8;
    --dark:#111827;
    --primary:#263f5c;
    --border:#dce6f0;
    --accent:#6ca6c8;
    --green:#35a67b;
}
*{box-sizing:border-box}
body{
    margin:0;
    font-family:Arial,sans-serif;
    background:var(--bg);
    color:#162033;
    padding-bottom:112px;
}
.header{
    padding:18px;
    background:linear-gradient(135deg,#111827,#263f5c);
    color:white;
    border-bottom-left-radius:28px;
    border-bottom-right-radius:28px;
}
.header h1{margin:0}
.header p{margin:8px 0 0;color:#e8edf4;font-weight:700}
.logout{display:inline-block;margin-top:8px;color:white;font-weight:bold}

.container{max-width:930px;margin:auto;padding:16px}
.card{
    background:white;
    border-radius:24px;
    padding:16px;
    margin-bottom:18px;
    box-shadow:0 8px 24px rgba(0,0,0,.08);
}
.section-title{margin:0 0 12px}
.scroll-hint{font-size:13px;color:#607086;margin:0 0 10px}

.top-brand{
    max-width:930px;
    margin:16px auto 0;
    padding:0 16px;
}
.logo-card{
    background:white;
    border-radius:24px;
    padding:16px;
    box-shadow:0 8px 24px rgba(0,0,0,.08);
    display:flex;
    align-items:center;
    gap:14px;
    margin-bottom:14px;
}
.logo-mark{
    width:54px;
    height:54px;
    border-radius:18px;
    display:grid;
    place-items:center;
    color:white;
    font-size:28px;
    font-weight:900;
    background:linear-gradient(135deg,var(--primary),var(--accent));
}
.logo-text strong{display:block;font-size:20px;color:var(--dark)}
.logo-text span{display:block;color:#607086;font-size:13px;margin-top:3px;line-height:1.35}

.top-grid{display:grid;grid-template-columns:1fr;gap:14px}
.metric-group{
    border:1px solid var(--border);
    border-radius:22px;
    background:linear-gradient(180deg,#ffffff,#f6faff);
    padding:14px;
}
.metric-group h3{margin:0 0 12px;color:var(--primary)}
.metric-bar-item{margin-bottom:14px}
.metric-bar-item:last-child{margin-bottom:0}
.metric-bar-top{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    margin-bottom:7px;
}
.metric-name{font-weight:800}
.metric-value{
    color:#607086;
    font-size:13px;
    font-weight:800;
    text-align:right;
    white-space:nowrap;
}
.metric-percent{
    margin-top:5px;
    font-size:12px;
    color:#607086;
}

.box-header{
    width:100%;
    border:none;
    background:transparent;
    padding:0;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    cursor:pointer;
    color:inherit;
    text-align:left;
}
.box-header h2{margin:0}
.toggle-icon{
    min-width:36px;
    height:36px;
    border-radius:50%;
    background:var(--dark);
    color:white;
    display:grid;
    place-items:center;
    font-size:22px;
}
.collapsible-content{margin-top:14px}
.card.collapsed .collapsible-content{display:none}

.meal-grid{display:grid;grid-template-columns:1fr;gap:14px}
@media(min-width:760px){.meal-grid{grid-template-columns:repeat(3,1fr)}}
.meal-box{
    border:1px solid var(--border);
    border-radius:22px;
    background:linear-gradient(180deg,#ffffff,#f6faff);
    padding:14px;
}
.meal-represent{
    min-height:120px;
    display:flex;
    flex-direction:column;
    justify-content:center;
    align-items:center;
    text-align:center;
}
.meal-represent p{margin:0;color:#607086;font-weight:700}
.goal-box{
    border:1px solid var(--border);
    border-radius:22px;
    background:linear-gradient(180deg,#ffffff,#f6faff);
    padding:28px;
    font-size:28px;
    font-weight:800;
    color:var(--primary);
    text-align:center;
}

.food-card-grid{
    display:flex;
    overflow-x:auto;
    gap:16px;
    padding:6px 2px 16px;
}
.food-card-box{
    flex:0 0 320px;
    border:1px solid var(--border);
    border-radius:24px;
    overflow:hidden;
    background:linear-gradient(180deg,#ffffff,#f6faff);
}
.food-image{
    min-height:135px;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:64px;
    background:linear-gradient(135deg,#e8f4ff,#fff7e6);
    border-bottom:1px solid var(--border);
}
.food-card-body{padding:15px}
.food-card-body h3{margin:0 0 6px}
.food-card-body p{margin:0 0 12px;color:#607086}
.nutrition-list{display:flex;flex-direction:column;gap:8px}
.nutrition-row{
    display:flex;
    justify-content:space-between;
    gap:10px;
    padding:9px 10px;
    background:white;
    border:1px solid #e7eef6;
    border-radius:14px;
}
.nutrition-value{color:#40536a;font-weight:700;font-size:13px}

.search-panel{display:grid;gap:14px}
.search-input{
    width:100%;
    border:1px solid var(--border);
    border-radius:18px;
    padding:14px 16px;
    font-size:16px;
    outline:none;
    background:#f8fbff;
}
.search-status{font-size:13px;color:#607086;margin:0}
.search-layout{display:grid;grid-template-columns:1fr;gap:14px}
@media(min-width:760px){.search-layout{grid-template-columns:1fr 1fr}}
.result-list,.detail-card{
    border:1px solid var(--border);
    border-radius:22px;
    background:linear-gradient(180deg,#ffffff,#f6faff);
    padding:10px;
    min-height:180px;
    max-height:420px;
    overflow-y:auto;
}
.result-item{
    width:100%;
    border:1px solid #e7eef6;
    border-radius:16px;
    background:white;
    padding:12px 14px;
    margin-bottom:9px;
    cursor:pointer;
    text-align:left;
    font-weight:800;
    color:var(--primary);
}
.result-item:hover,.result-item.active{
    background:#eef6ff;
    border-color:var(--accent);
}
.detail-card h3{margin:0 0 10px;color:var(--primary)}
.detail-bar-row{
    padding:12px 0;
    border-bottom:1px solid #e7eef6;
}
.detail-bar-top{
    display:flex;
    justify-content:space-between;
    gap:12px;
    margin-bottom:8px;
}
.detail-bar-label{font-weight:800;color:#40536a}
.detail-bar-value{color:#607086;font-size:13px;font-weight:800;text-align:right}
.detail-bar-track{
    height:14px;
    border-radius:999px;
    background:#e8edf4;
    overflow:hidden;
}
.detail-bar-fill{
    height:100%;
    border-radius:999px;
    background:linear-gradient(90deg,var(--green),var(--accent));
}
.detail-bar-percent{
    margin-top:5px;
    color:#607086;
    font-size:12px;
    font-weight:700;
}
.empty-note{color:#607086;margin:0;line-height:1.45}
.shopping-list{margin:0;padding-left:20px}
.shopping-list li{margin-bottom:8px}

.app-nav{
    position:fixed;
    left:50%;
    bottom:0;
    transform:translateX(-50%);
    width:min(930px,100%);
    background:white;
    border-radius:28px 28px 0 0;
    box-shadow:0 -10px 30px rgba(17,24,39,.16);
    padding:10px 10px calc(10px + env(safe-area-inset-bottom));
    z-index:900;
}
.nav-scroll{
    display:grid;
    grid-template-columns:repeat(6,1fr);
    gap:4px;
}
.nav-btn{
    border:0;
    border-radius:20px;
    padding:8px 4px;
    background:transparent;
    color:#607086;
    font-weight:800;
    cursor:pointer;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    min-height:66px;
}
.nav-icon{font-size:23px;margin-bottom:5px}
.nav-label{font-size:10px;line-height:1.1}
.nav-btn.active{background:#eef6ff;color:var(--primary)}
.page-section{display:none}
.page-section.active{display:block}

.save-nutrition-button{
    width:100%;
    border:none;
    border-radius:14px;
    background:#263f5c;
    color:white;
    padding:14px;
    margin-top:16px;
    font-size:15px;
    font-weight:800;
    cursor:pointer;
}

.save-nutrition-button:hover{
    background:#111827;
}

.save-nutrition-button:disabled{
    opacity:.6;
    cursor:not-allowed;
}

#saveNutritionStatus{
    margin-top:10px;
}

#saveNutritionStatus.success{
    color:#35a67b;
    font-weight:700;
}

#saveNutritionStatus.error{
    color:#e86969;
    font-weight:700;
}