
*{
    box-sizing:border-box
}

body{
    margin:0;
    background:#0f172a;
    color:#f8fafc;
    font-family:Inter,Arial,sans-serif;
    padding-bottom:70px
}

header{
    height:70px;
    background:#1e293b;
    border-bottom:1px solid #334155;
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:0 max(20px,calc((100% - 1100px)/2));
    position:sticky;
    top:0;
    z-index:5
}

header b,
.brand{
    font-size:22px;
    color:#22c55e;
    font-weight:800
}

nav{
    display:flex;
    gap:22px;
    align-items:center
}

nav a{
    color:#94a3b8;
    text-decoration:none;
    font-weight:600
}

nav .active,
nav a:hover{
    color:#22c55e
}

button{
    border:0;
    border-radius:8px;
    padding:10px 14px;
    font-weight:700;
    cursor:pointer;
    background:#ef4444;
    color:white
}

/* ============================================================
   EDIT BUTTON
   ============================================================ */

.edit-button{
    background:#22c55e;
    color:#052e16;
}

.edit-button:hover{
    background:#16a34a;
    color:#052e16;
}

/* ============================================================
   PAGE
   ============================================================ */

main{
    max-width:1100px;
    margin:auto;
    padding:30px 18px
}

h1{
    text-align:center;
    font-size:28px
}

h2{
    font-size:19px
}

h3{
    font-size:15px;
    color:#94a3b8;
    margin-top:22px;
    margin-bottom:10px;
}

.welcome{
    text-align:center;
    color:#94a3b8
}

.goals{
    display:block;
    width:max-content;
    margin:20px auto;
    color:#60a5fa;
    text-decoration:none;
    border:1px solid #2563eb;
    border-radius:8px;
    padding:9px 16px
}

section{
    background:#1e293b;
    border:1px solid #334155;
    border-radius:15px;
    padding:20px;
    margin:18px 0
}

.cards{
    display:grid;
    grid-template-columns:repeat(4,1fr);
    gap:12px;
    margin-top:12px
}

.metric{
    background:#0b1220;
    border:1px solid #334155;
    border-radius:10px;
    text-align:center;
    padding:18px
}

.metric small{
    display:block;
    color:#94a3b8;
    font-size:11px;
    text-transform:uppercase
}

.metric strong{
    display:block;
    font-size:26px;
    margin-top:8px
}

.remain{
    border-color:#4ade80
}

.remain strong{
    color:#22c55e
}

/* ============================================================
   STREAKS & BADGES
   ============================================================ */

.badges-grid{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:12px;
    margin-top:12px;
}

.badge-item{
    background:#0b1220;
    border:1px solid #334155;
    border-radius:10px;
    padding:16px 12px;
    text-align:center;
}

.badge-icon{
    font-size:32px;
    line-height:1;
    margin-bottom:10px;
}

.badge-name{
    color:#f8fafc;
    font-size:13px;
    font-weight:700;
    margin-bottom:5px;
}

.badge-desc{
    color:#64748b;
    font-size:11px;
    line-height:1.4;
}

.upcoming-list{
    display:flex;
    flex-direction:column;
    gap:8px;
    margin-top:12px;
}

.upcoming-item{
    display:flex;
    align-items:center;
    gap:12px;
    background:#0b1220;
    border:1px solid #334155;
    border-radius:10px;
    padding:12px;
}

.up-icon{
    font-size:26px;
    flex-shrink:0;
}

.up-info{
    flex:1;
    min-width:0;
}

.up-name{
    color:#f8fafc;
    font-size:13px;
    font-weight:700;
}

.up-desc{
    color:#64748b;
    font-size:11px;
    margin-top:3px;
}

.up-progress{
    color:#22c55e;
    font-size:12px;
    font-weight:700;
    white-space:nowrap;
}

/* ============================================================
   MEAL ENTRY
   ============================================================ */

textarea{
    width:100%;
    min-height:130px;
    background:#0b1220;
    border:1px solid #475569;
    border-radius:10px;
    padding:14px;
    color:white;
    font:inherit
}

.primary,
.purple,
.green{
    width:100%;
    margin-top:10px
}

.primary{
    background:#22c55e;
    color:#052e16
}

.purple{
    background:#7c3aed
}

.green{
    background:#059669
}

/* ============================================================
   TABLE
   ============================================================ */

.table{
    overflow-x:auto
}

table{
    width:100%;
    border-collapse:collapse;
    min-width:650px
}

th,
td{
    padding:11px;
    border-bottom:1px solid #334155;
    text-align:left;
    font-size:13px
}

th{
    color:#94a3b8
}

/* ============================================================
   LOGIN
   ============================================================ */

.login{
    min-height:100vh;
    display:grid;
    place-items:center;
    padding:20px
}

.login-card{
    width:min(420px,100%);
    background:#1e293b;
    border:1px solid #334155;
    border-radius:18px;
    padding:35px;
    text-align:center
}

.login-card p{
    color:#94a3b8
}

.login-card h1{
    font-size:25px
}

.login-card .brand{
    margin-bottom:20px
}

.login-card #g{
    display:flex;
    justify-content:center;
    margin-top:25px
}

.login-card #err{
    color:#ef4444;
    margin-top:15px
}

.mobile-nav{
    display:none
}

/* ============================================================
   MOBILE
   ============================================================ */

@media(max-width:767px){

    header{
        display:none
    }

    main{
        padding:20px 12px
    }

    h1{
        font-size:22px
    }

    .cards{
        grid-template-columns:1fr 1fr
    }

    .badges-grid{
        grid-template-columns:1fr 1fr
    }

    .badge-item{
        padding:14px 8px
    }

    .badge-icon{
        font-size:28px
    }

    .mobile-nav{
        display:flex;
        position:fixed;
        bottom:0;
        left:0;
        right:0;
        background:#1e293b;
        border-top:1px solid #334155;
        justify-content:space-around;
        padding:8px;
        z-index:10
    }

    .mobile-nav a{
        font-size:20px;
        text-align:center;
        color:#94a3b8
    }

    .mobile-nav small{
        display:block;
        font-size:10px
    }

    .table{
        margin:0 -10px;
        padding:0 10px
    }

}

/* ============================================================
   INTERMITTENT FASTING
   ============================================================ */

.fasting-section h2{
    margin-bottom:16px;
}

.fast-type-select{
    display:flex;
    gap:8px;
    margin-bottom:12px;
}

.fast-type-btn{
    flex:1;
    padding:10px 8px;
    background:#0b1220;
    border:1px solid #334155;
    border-radius:8px;
    color:#94a3b8;
    font-size:13px;
    font-weight:700;
    cursor:pointer;
}

.fast-type-btn.active{
    background:#22c55e;
    border-color:#22c55e;
    color:#052e16;
}

.fast-type-btn:hover{
    border-color:#22c55e;
}

.fast-start-btn{
    width:100%;
    background:#22c55e;
    color:#052e16;
    border:none;
    border-radius:8px;
    padding:11px 14px;
    font-size:14px;
    font-weight:800;
    cursor:pointer;
}

.fast-start-btn:hover{
    background:#16a34a;
}

/* ============================================================
   ACTIVE FAST
   ============================================================ */

.fasting-ring{
    position:relative;
    width:220px;
    height:220px;
    margin:10px auto 18px;
}

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

.ring-bg{
    fill:none;
    stroke:#334155;
    stroke-width:10;
}

.ring-fill{
    fill:none;
    stroke:#22c55e;
    stroke-width:10;
    stroke-linecap:round;
    transition:stroke-dashoffset .5s linear;
}

.ring-center{
    position:absolute;
    inset:0;
    display:flex;
    flex-direction:column;
    justify-content:center;
    align-items:center;
}

.ring-time{
    font-size:27px;
    font-weight:800;
    color:#f8fafc;
}

.ring-label{
    margin-top:4px;
    color:#94a3b8;
    font-size:12px;
}

.fast-info{
    text-align:center;
    color:#22c55e;
    font-size:14px;
    font-weight:700;
    margin-bottom:14px;
}

.fast-end-btn{
    width:100%;
    background:#ef4444;
    color:white;
    border:none;
    border-radius:8px;
    padding:11px 14px;
    font-size:14px;
    font-weight:800;
    cursor:pointer;
}

/* ============================================================
   FASTING STATS
   ============================================================ */

.fast-streak{
    display:flex;
    gap:12px;
    margin-top:16px;
}

.fast-streak-item{
    flex:1;
    background:#0b1220;
    border:1px solid #334155;
    border-radius:10px;
    text-align:center;
    padding:12px;
}

.fs-val{
    font-size:22px;
    font-weight:800;
    color:#22c55e;
}

.fs-lbl{
    margin-top:4px;
    color:#64748b;
    font-size:11px;
    text-transform:uppercase;
}

@media(max-width:767px){

    .fast-type-select{
        gap:6px;
    }

    .fast-type-btn{
        padding:10px 4px;
        font-size:12px;
    }

}

/* ============================================================
   AI MEAL SUGGESTIONS
   ============================================================ */

.ai-suggestions-section {
    margin-top: 24px;
}

.ai-suggestions-section h2 {
    color: #ffffff;
    font-size: 16px;
    margin-bottom: 12px;
}

.ai-suggestions-section .suggest-btn {
    width: 100%;
    background: #7c3aed !important;
    color: #ffffff !important;
    border: none;
    border-radius: 8px;
    padding: 11px 14px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
}

.ai-suggestions-section .suggest-btn:hover {
    background: #6d28d9 !important;
}

.ai-suggestions-section .suggest-btn:disabled {
    background: #7c3aed !important;
    color: #ffffff !important;
    opacity: 0.7;
}

.sg-remaining {
    color: #9ca3af;
    font-size: 12px;
    text-align: center;
    margin: 12px 0;
}

.suggestion-card {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 14px;
    margin-top: 12px;
}

.sg-name {
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
}

.sg-macros {
    color: #22c55e;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
}

.sg-desc {
    color: #9ca3af;
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 10px;
}

.sg-log-btn {
    width: 100%;
    background: #22c55e !important;
    color: #ffffff !important;
    border: none;
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.sg-log-btn:hover {
    background: #16a34a !important;
}

/* Loading timer for meal suggestions */

.sg-loading {
    text-align: center;
    padding: 32px 16px;
}

.sg-spinner {
    width: 36px;
    height: 36px;
    border: 4px solid #1e293b;
    border-top: 4px solid #7c3aed;
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: sg-spin 0.8s linear infinite;
}

@keyframes sg-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.sg-loading-text {
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.sg-timer {
    color: #9ca3af;
    font-size: 12px;
    margin-bottom: 12px;
}

.sg-close-btn {
    background: #374151 !important;
    color: #f87171 !important;
    border: 1px solid #4b5563;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.sg-close-btn:hover {
    background: #4b5563 !important;
}

.sg-close-results {
    display: block;
    margin: 0 0 12px auto;
}

/* ============================================================
   QUICK ADD FAVORITES
   ============================================================ */

.favorites-section {
    background: #1e293b;
    border-radius: 12px;
    padding: 16px;
    margin-top: 20px;
    border: 1px solid #334155;
}

.favorites-section h3 {
    font-size: 14px;
    color: #fbbf24;
    margin-bottom: 12px;
    font-weight: 700;
}

.fav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
}

.fav-card {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 10px;
}

.fav-card .fav-name {
    font-size: 12px;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 4px;
}

.fav-card .fav-macros {
    font-size: 10px;
    color: #22c55e;
    margin-bottom: 6px;
}

.fav-card .fav-actions {
    display: flex;
    gap: 4px;
}

.fav-card .fav-actions button {
    flex: 1;
    padding: 6px;
    border: none;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
}

.fav-card .fav-actions .log-btn {
    background: #22c55e !important;
    color: #0f172a !important;
}

.fav-card .fav-actions .del-btn {
    background: #ef4444 !important;
    color: white !important;
}

.fav-add-btn {
    width: 100%;
    background: #f59e0b !important;
    color: #ffffff !important;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 10px;
}

.fav-add-btn:hover {
    background: #d97706 !important;
}

.fav-input {
    width: 100%;
    background: #0f172a;
    color: #9ca3af;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    box-sizing: border-box;
}

.fav-input::placeholder {
    color: #64748b;
}

.fav-field {
    flex: 1;
    background: #0f172a;
    color: #9ca3af;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 10px 8px;
    font-size: 12px;
    box-sizing: border-box;
}

.fav-field::placeholder {
    color: #64748b;
}

.fav-save-btn {
    width: 100%;
    background: #22c55e !important;
    color: #ffffff !important;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 12px;
}

.fav-save-btn:hover {
    background: #16a34a !important;
}

