/**
 * ══════════════════════════════════════════════════
 *  NUTRÊ , Components
 *  Buttons, cards, badges, modals, fields, toasts,
 *  skeletons, empty states, loader.
 * ══════════════════════════════════════════════════
 */

/* ── Acessibilidade ────────────────────────
   Rótulos lidos apenas por leitores de tela. Sem esta regra global, labels
   marcados como sr-only apareciam soltos no layout do painel. */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ── 3D Buttons ──────────────────────────── */
.btn-3d {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 22px;
    background: var(--3d-bg);
    color: var(--3d-text) !important;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 6px 0 var(--3d-shadow), 0 12px 20px rgba(0,0,0,0.15);
    text-decoration: none;
}
.btn-3d:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--3d-shadow), 0 15px 25px rgba(0,0,0,0.2); filter: brightness(1.1); }
.btn-3d:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--3d-shadow), 0 5px 10px rgba(0,0,0,0.1); }
.btn-3d::after {
    content: ''; position: absolute; top: 3px; left: 4px; right: 4px; height: 35%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.15), transparent);
    border-radius: 10px 10px 100% 100%; pointer-events: none;
}

/* ── Standard Buttons ────────────────────── */
.btn-submit {
    width: 100%; padding: 14px; background: var(--green-900); color: #fff;
    border: none; border-radius: 12px; font-family: inherit; font-size: 15px;
    font-weight: 600; cursor: pointer; transition: var(--transition);
    box-shadow: 0 4px 12px rgba(28,61,46,0.15);
}
.btn-submit:hover { background: var(--green-700); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(28,61,46,0.25); }
.btn-submit:active { transform: translateY(0); }

.btn-google {
    width: 100%; display: flex; align-items: center; justify-content: center;
    gap: 12px; padding: 12px; border: 1.5px solid var(--border);
    border-radius: 12px; background: #fff; cursor: pointer; font-family: inherit;
    font-size: 14px; font-weight: 500; color: var(--text-main); transition: var(--transition);
}
.btn-google:hover { background: #f8f8f8; border-color: rgba(0,0,0,0.15); box-shadow: var(--shadow-sm); }

.google-signin-wrap { width: 100%; min-height: 44px; }
.google-signin-button { width: 100%; min-height: 44px; display: flex; justify-content: center; }
.google-signin-button > div { width: 100% !important; max-width: 400px; }
.google-signin-button iframe { max-width: 100%; }
.google-signin-status { margin: 8px 0 0; color: var(--danger, #b42318); font-size: 13px; line-height: 1.4; text-align: center; }

.btn-back {
    width: 100%; padding: 12px; background: transparent; color: var(--text-muted);
    border: 1.5px solid var(--border); border-radius: 12px; font-size: 14px;
    cursor: pointer; margin-top: 1rem; transition: var(--transition);
}
.btn-back:hover { background: var(--green-100); color: var(--green-900); border-color: var(--green-500); }

.btn.secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    height: auto;
    background: var(--green-100);
    color: var(--green-900);
    border: 1.5px solid transparent;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn.secondary:hover { background: #fff; border-color: var(--green-500); transform: translateY(-2px); box-shadow: var(--shadow-sm); }

.btn-icon {
    background: transparent; border: none; color: var(--text-muted); cursor: pointer;
    padding: 8px; border-radius: 10px; transition: all 0.2s ease;
    display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--green-50); color: var(--green-900); transform: translateY(-1px); }

/* ── Cards ───────────────────────────────── */
.card {
    background: var(--bg-surface); border-radius: var(--radius-lg); padding: 2.5rem;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border); transition: var(--transition);
}
.card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }

.data-card {
    background: var(--bg-surface); border-radius: 30px; border: 1px solid var(--border);
    overflow: hidden; box-shadow: var(--shadow-md);
}

/* ── Badges ──────────────────────────────── */
.badge {
    padding: 6px 12px; border-radius: 8px; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em; display: inline-flex; align-items: center;
}
.badge.secondary { background: var(--border); color: var(--text-muted); }
.badge.info { background: #DBEAFE; color: #1E40AF; }
.badge.primary { background: var(--green-100); color: var(--green-900); }
.badge.success { background: #DEF7EC; color: #03543F; }

/* ── User Avatars ────────────────────────── */
.user-avatar {
    background: var(--green-100); border-radius: 12px; display: flex;
    align-items: center; justify-content: center; overflow: hidden;
    position: relative; transition: all 0.3s ease; flex-shrink: 0;
}
.user-avatar.mini { width: 36px; height: 36px; border-radius: 10px; }
.user-avatar.xl { width: 80px; height: 80px; border-radius: 22px; }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── Fields & Inputs ─────────────────────── */
.field { margin-bottom: 0.8rem !important; }
.field label {
    font-size: 13px; font-weight: 700; color: var(--green-900); margin-bottom: 8px;
    display: block; text-transform: uppercase; letter-spacing: 0.04em;
}
.field-wrap { position: relative; display: flex; align-items: center; }
.field-icon {
    position: absolute; left: 14px; color: var(--text-light); display: flex;
    align-items: center; transition: color 0.3s ease; z-index: 1; pointer-events: none;
}
.field-wrap input, .field-wrap select, .field-wrap textarea {
    width: 100%; padding: 14px 16px 14px 44px; border: 1.5px solid var(--border);
    border-radius: 14px; font-size: 14px; font-family: 'Outfit', sans-serif;
    color: var(--text-main); background: var(--bg-surface); outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); appearance: none;
}
.field-wrap.no-icon input, .field-wrap.no-icon select, .field-wrap.no-icon textarea { padding-left: 16px; }

input::placeholder, textarea::placeholder { color: var(--text-light); font-weight: 400; opacity: 0.5; transition: color 0.2s ease; }
input:focus::placeholder, textarea:focus::placeholder { color: transparent; }
.field-wrap input:focus, .field-wrap select:focus, .field-wrap textarea:focus {
    border-color: var(--green-500); background: var(--bg-surface); box-shadow: 0 0 0 4px rgba(82,183,136,0.12);
}
.field-wrap:focus-within .field-icon { color: var(--green-700); }
.field-wrap select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%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;
}
.field input:not(.field-wrap input), .field select:not(.field-wrap select), .field textarea:not(.field-wrap textarea) {
    width: 100%; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: 14px;
    font-size: 14px; font-family: 'Outfit', sans-serif; color: var(--text-main);
    background: var(--bg-surface); outline: none; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.field input:not(.field-wrap input):focus, .field select:not(.field-wrap select):focus, .field textarea:not(.field-wrap textarea):focus {
    border-color: var(--green-500); background: var(--bg-surface); box-shadow: 0 0 0 4px rgba(82,183,136,0.12);
}
.field-action {
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; color: var(--text-light);
    display: flex; padding: 4px; transition: var(--transition);
}
.field-action:hover { color: var(--green-700); }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem !important; }
.field.full { grid-column: span 2; }

/* ── Separator ───────────────────────────── */
.divider-row { display: flex; align-items: center; gap: 15px; margin: 2rem 0; }
.divider-line { flex: 1; height: 1px; background: var(--border); }
.divider-text { font-size: 12px; color: var(--text-light); white-space: nowrap; }

/* ── Error Messages ──────────────────────── */
.error-msg {
    display: none; align-items: center; gap: 10px; padding: 12px 16px;
    background: #fff5f5; border-left: 4px solid var(--coral); border-radius: 8px;
    margin-bottom: 1.5rem; font-size: 14px; color: #c53030;
}
.error-msg.show { display: flex; animation: slideDown 0.3s ease both; }

/* ── Modal system ────────────────────────── */
body.has-open-modal { overflow: hidden !important; }

.modal-overlay {
    position: fixed !important;
    inset: 0 !important;
    box-sizing: border-box;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    padding: clamp(12px, 3vh, 28px) clamp(10px, 3vw, 28px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    /* O conteúdo atrás continua reconhecível, mas perde prioridade visual. */
    background: rgba(8, 31, 24, 0.58);
    backdrop-filter: blur(10px) saturate(.86) !important;
    -webkit-backdrop-filter: blur(10px) saturate(.86) !important;
    z-index: 100000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.modal-overlay.show,
.modal-overlay.active,
.modal-overlay[style*="display: flex"],
.modal-overlay[style*="display:flex"] {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-overlay:not(.show):not(.active):not([style*="display: flex"]):not([style*="display:flex"]) {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

body .modal-overlay > .modal,
body .modal-overlay > .modal-card {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: min(100%, 720px);
    max-width: 720px;
    max-height: calc(100vh - 24px) !important;
    max-height: calc(100dvh - 24px) !important;
    max-height: 100% !important;
    min-height: 0;
    margin: auto;
    padding: 0 !important;
    overflow: hidden !important;
    background: var(--bg-surface, #fff);
    border: 1px solid rgba(27, 82, 64, 0.14);
    border-radius: 14px;
    box-shadow: 0 20px 48px rgba(5, 35, 25, 0.24);
    transform: translateY(12px) scale(0.985);
    transform-origin: center;
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Os diálogos nativos do prontuário seguem a mesma camada de foco. */
dialog::backdrop {
    background: rgba(8, 31, 24, 0.58);
    backdrop-filter: blur(10px) saturate(.86) !important;
    -webkit-backdrop-filter: blur(10px) saturate(.86) !important;
}

body .modal-overlay > .modal.modal-xl { width: min(100%, 920px); max-width: 920px; }

.modal-overlay.show > .modal,
.modal-overlay.active > .modal,
.modal-overlay[style*="display: flex"] > .modal,
.modal-overlay[style*="display:flex"] > .modal {
    transform: translateY(0) scale(1);
}

body .modal-overlay > .modal > .modal-header {
    position: relative;
    z-index: 3;
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr) 40px;
    flex: 0 0 auto;
    align-items: center;
    gap: 16px;
    min-width: 0;
    margin: 0 !important;
    padding: 20px 26px;
    border-bottom: 1px solid var(--border, #dce8e2);
    background: linear-gradient(180deg, #fff 0%, #fcfefd 100%);
}

body .modal-overlay > .modal > .modal-header::before {
    content: '';
    grid-column: 1;
    grid-row: 1;
    width: 62px;
    height: 62px;
    border: 1px solid var(--green-100, #dceee4);
    border-radius: 15px;
    background: var(--green-50, #f0f7f3) url('../assets/nutrielo-mark.webp') center / 38px 38px no-repeat;
}

body .modal-overlay > .modal > .modal-header:has(> .modal-header-icon)::before { display: none; }

.modal-header-icon {
    grid-column: 1 !important;
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    border: 1px solid var(--green-100, #dceee4);
    border-radius: 15px;
    background: var(--green-50, #f0f7f3);
    color: var(--green-700, #176b50);
}

.modal-header-icon svg { width: 34px; height: 34px; }

body .modal-overlay > .modal > .modal-header:has(> .modal-header-icon) > :nth-child(2) {
    grid-column: 2;
    min-width: 0;
}

body .modal-overlay > .modal > .modal-header > :first-child {
    grid-column: 2;
    min-width: 0;
}

body .modal-overlay > .modal > .modal-header > .btn-close {
    grid-column: 3;
    justify-self: end;
}

body .modal-overlay > .modal > .modal-header h3 {
    margin: 0;
    color: var(--green-900, #123e31);
    font-family: 'DM Serif Display', serif;
    font-size: clamp(22px, 2.2vw, 27px);
    font-weight: 400;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

body .modal-overlay > .modal > .modal-header h3 > svg,
body .modal-overlay > .modal > :first-child:has(> h3):not(.modal-header) > h3 > svg {
    display: none;
}

body .modal-overlay > .modal > .modal-header p,
body .modal-overlay > .modal > .modal-header small {
    display: block;
    margin: 4px 0 0 !important;
    color: var(--text-muted, #64756f);
    font-size: 13px;
    line-height: 1.35;
}

/* Compatibilidade para janelas antigas que ainda nao nomeiam cabecalho e rodape.
   O seletor fica restrito aos filhos diretos do dialogo para nao alterar cartoes internos. */
body .modal-overlay > .modal > :first-child:has(> h3):not(.modal-header) {
    position: relative;
    z-index: 3;
    display: grid !important;
    grid-template-columns: 62px minmax(0, 1fr) 40px;
    align-items: center !important;
    gap: 16px;
    flex: 0 0 auto;
    min-width: 0;
    padding: 20px 26px !important;
    border-bottom: 1px solid var(--border, #dce8e2) !important;
    background: linear-gradient(180deg, #fff 0%, #fcfefd 100%) !important;
}

body .modal-overlay > .modal > :first-child:has(> h3):not(.modal-header)::before {
    content: '';
    width: 62px;
    height: 62px;
    border: 1px solid var(--green-100, #dceee4);
    border-radius: 15px;
    background: var(--green-50, #f0f7f3) url('../assets/nutrielo-mark.webp') center / 38px 38px no-repeat;
}

body .modal-overlay > .modal > :first-child:has(> h3):not(.modal-header) > h3 {
    min-width: 0;
    margin: 0 !important;
    color: var(--green-900, #123e31) !important;
    font-family: 'DM Serif Display', serif !important;
    font-size: clamp(22px, 2.2vw, 27px) !important;
    font-weight: 400 !important;
}

body .modal-overlay > .modal > :first-child:has(> h3):not(.modal-header) > button:last-child {
    justify-self: end;
    width: 38px !important;
    height: 38px !important;
    border: 1px solid transparent !important;
    border-radius: 50% !important;
    background: var(--green-50, #f0f7f3) !important;
    color: var(--green-900, #123e31) !important;
}

body .modal-overlay > .modal > :last-child:has(> .btn):not(.modal-footer):not(.modal-body) {
    position: relative;
    z-index: 3;
    display: flex !important;
    flex: 0 0 auto;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 10px !important;
    min-height: 72px;
    padding: 14px 26px 16px !important;
    border-top: 1px solid var(--border, #dce8e2) !important;
    border-radius: 0 !important;
    background: #fff !important;
}

.btn-close {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid transparent !important;
    border-radius: 50%;
    background: var(--green-50, #f0f7f3) !important;
    color: var(--green-900, #123e31) !important;
    font-size: 22px !important;
    line-height: 1;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.btn-close:hover {
    border-color: rgba(180, 35, 24, 0.16) !important;
    background: #fff0ee !important;
    color: #b42318 !important;
    transform: translateY(-1px);
}

.btn-close:focus-visible { outline: 3px solid rgba(82, 183, 136, 0.24); outline-offset: 2px; }

body .modal-overlay > .modal > [style*="linear-gradient"] > .btn-close {
    border-color: rgba(255, 255, 255, 0.18) !important;
    background: rgba(255, 255, 255, 0.14) !important;
    color: #fff !important;
}

body .modal-overlay > .modal > [style*="linear-gradient"] > .btn-close:hover {
    border-color: rgba(255, 255, 255, 0.3) !important;
    background: rgba(255, 255, 255, 0.24) !important;
    color: #fff !important;
}

body .modal-overlay > .modal > form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

body .modal-overlay > .modal > .modal-body,
body .modal-overlay > .modal > .app-modal-body,
body .modal-overlay > .modal > form > .modal-body,
body .modal-overlay > .modal > form.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0 !important;
    padding: 18px 26px;
    background: #fcfdfc;
    overflow-x: hidden;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    contain: layout paint;
    scroll-behavior: auto;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

body .modal-overlay > .modal .modal-section,
body .modal-overlay > .modal .modal-body > section,
body .modal-overlay > .modal .app-modal-body > section {
    padding: 16px 18px;
    border: 1px solid var(--border, #dce8e2);
    border-radius: 13px;
    background: linear-gradient(145deg, #fff 0%, var(--green-50, #f0f7f3) 145%);
}

body .modal-overlay > .modal .modal-section + .modal-section,
body .modal-overlay > .modal .app-modal-body > section + section { margin-top: 12px; }

.modal-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 4px;
    color: var(--green-900, #123e31);
    font-size: 15px;
    font-weight: 800;
}

.modal-section-title::before {
    content: '';
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--green-600, #2d8a63);
    box-shadow: 0 0 0 7px var(--green-50, #f0f7f3);
}

.modal-section-description {
    margin: 0 0 12px;
    padding-left: 19px;
    color: var(--text-muted, #64756f);
    font-size: 12px;
    line-height: 1.4;
}

body .modal-overlay > .modal > form.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

body .modal-overlay > .modal .modal-footer {
    position: relative;
    z-index: 3;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-height: 72px;
    margin: 0 !important;
    padding: 14px 26px 16px;
    border-top: 1px solid var(--border, #dce8e2);
    background: #fff;
}

body .modal-overlay > .modal > form.modal-body > .modal-footer {
    position: sticky;
    bottom: -22px;
    margin: 6px -24px -22px !important;
}

body .modal-overlay > .modal .modal-body,
body .modal-overlay > .modal .app-modal-body,
body .modal-overlay > .modal form.modal-body,
body .modal-overlay > .modal .food-search-panel,
body .modal-overlay > .modal .food-nutrition-panel {
    scrollbar-width: auto;
    scrollbar-color: var(--green-500, #52b788) var(--green-50, #f0f7f3);
}

body .modal-overlay > .modal > [style*="overflow-y: auto"],
body .modal-overlay > .modal > [style*="overflow-y:auto"] {
    min-height: 0;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-width: auto;
    scrollbar-color: var(--green-500, #52b788) var(--green-50, #f0f7f3);
}

body .modal-overlay > .modal .modal-body::-webkit-scrollbar,
body .modal-overlay > .modal .app-modal-body::-webkit-scrollbar,
body .modal-overlay > .modal form.modal-body::-webkit-scrollbar,
body .modal-overlay > .modal .food-search-panel::-webkit-scrollbar,
body .modal-overlay > .modal .food-nutrition-panel::-webkit-scrollbar,
body .modal-overlay > .modal > [style*="overflow-y: auto"]::-webkit-scrollbar,
body .modal-overlay > .modal > [style*="overflow-y:auto"]::-webkit-scrollbar { width: 10px; }

body .modal-overlay > .modal .modal-body::-webkit-scrollbar-track,
body .modal-overlay > .modal .app-modal-body::-webkit-scrollbar-track,
body .modal-overlay > .modal form.modal-body::-webkit-scrollbar-track,
body .modal-overlay > .modal .food-search-panel::-webkit-scrollbar-track,
body .modal-overlay > .modal .food-nutrition-panel::-webkit-scrollbar-track,
body .modal-overlay > .modal > [style*="overflow-y: auto"]::-webkit-scrollbar-track,
body .modal-overlay > .modal > [style*="overflow-y:auto"]::-webkit-scrollbar-track { background: var(--green-50, #f0f7f3); }

body .modal-overlay > .modal .modal-body::-webkit-scrollbar-thumb,
body .modal-overlay > .modal .app-modal-body::-webkit-scrollbar-thumb,
body .modal-overlay > .modal form.modal-body::-webkit-scrollbar-thumb,
body .modal-overlay > .modal .food-search-panel::-webkit-scrollbar-thumb,
body .modal-overlay > .modal .food-nutrition-panel::-webkit-scrollbar-thumb,
body .modal-overlay > .modal > [style*="overflow-y: auto"]::-webkit-scrollbar-thumb,
body .modal-overlay > .modal > [style*="overflow-y:auto"]::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: var(--green-500, #52b788);
    background-clip: padding-box;
}

@media (max-width: 640px) {
    .modal-overlay {
        padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    }

    body .modal-overlay > .modal,
    body .modal-overlay > .modal.modal-xl {
        width: 100%;
        max-width: none;
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
        max-height: 100%;
        border-radius: 17px;
    }

    body .modal-overlay > .modal > .modal-header { padding: 18px 18px 15px; }
    body .modal-overlay > .modal > .modal-header {
        grid-template-columns: 48px minmax(0, 1fr) 38px;
        gap: 12px;
    }
    body .modal-overlay > .modal > .modal-header::before { width: 48px; height: 48px; border-radius: 12px; background-size: 30px 30px; }
    .modal-header-icon { width: 48px; height: 48px; border-radius: 12px; }
    .modal-header-icon svg { width: 28px; height: 28px; }
    body .modal-overlay > .modal > :first-child:has(> h3):not(.modal-header) {
        grid-template-columns: 48px minmax(0, 1fr) 38px;
        gap: 12px;
        padding: 18px !important;
    }
    body .modal-overlay > .modal > :first-child:has(> h3):not(.modal-header)::before { width: 48px; height: 48px; border-radius: 12px; background-size: 30px 30px; }
    body .modal-overlay > .modal > .modal-header h3 { font-size: 22px; }
    body .modal-overlay > .modal > .modal-body,
    body .modal-overlay > .modal > .app-modal-body,
    body .modal-overlay > .modal > form > .modal-body,
    body .modal-overlay > .modal > form.modal-body { padding: 18px; }

    body .modal-overlay > .modal .modal-footer {
        min-height: 0;
        padding: 12px 18px max(14px, env(safe-area-inset-bottom));
    }

    body .modal-overlay > .modal > form.modal-body > .modal-footer {
        bottom: -18px;
        margin: 4px -18px -18px !important;
    }

    body .modal-overlay > .modal .modal-footer:not(.care-sticky-footer) { flex-direction: column-reverse; align-items: stretch; }
    body .modal-overlay > .modal .modal-footer:not(.care-sticky-footer) .btn,
    body .modal-overlay > .modal .modal-footer:not(.care-sticky-footer) button { width: 100%; margin: 0 !important; }
}

@media (max-height: 680px) {
    .modal-overlay { padding-top: 8px; padding-bottom: 8px; }
    body .modal-overlay > .modal,
    body .modal-overlay > .modal.modal-xl {
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
        max-height: 100%;
    }
}

/* ── Toast Notification System ───────────── */
.nutre-toast-container {
    position: fixed; top: 24px; right: 24px; z-index: 99999;
    display: flex; flex-direction: column; gap: 12px; pointer-events: none;
}
.nutre-toast {
    display: flex; align-items: center; gap: 14px; padding: 16px 22px;
    border-radius: 16px; background: #fff;
    box-shadow: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
    border-left: 4px solid var(--green-500);
    min-width: 320px; max-width: 440px; pointer-events: auto;
    transform: translateX(120%); opacity: 0;
    animation: toastSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    font-family: 'Outfit', sans-serif; position: relative; overflow: hidden;
}
.nutre-toast.toast-leaving { animation: toastSlideOut 0.4s cubic-bezier(0.6, -0.28, 0.74, 0.05) forwards; }
.nutre-toast.toast-error { border-left-color: var(--coral); }
.nutre-toast.toast-warning { border-left-color: #F59E0B; }
.nutre-toast.toast-info { border-left-color: #3B82F6; }
.nutre-toast-icon { width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nutre-toast .nutre-toast-icon { background: var(--green-100); color: var(--green-700); }
.nutre-toast.toast-error .nutre-toast-icon { background: #FEF2F2; color: var(--coral); }
.nutre-toast.toast-warning .nutre-toast-icon { background: #FFFBEB; color: #D97706; }
.nutre-toast.toast-info .nutre-toast-icon { background: #EFF6FF; color: #2563EB; }
.nutre-toast-body { flex: 1; min-width: 0; }
.nutre-toast-title { font-weight: 700; font-size: 14px; color: var(--green-900); margin-bottom: 2px; line-height: 1.3; }
.nutre-toast-msg { font-size: 13px; color: var(--text-muted); line-height: 1.4; }
.nutre-toast-close {
    background: none; border: none; color: var(--text-light); cursor: pointer;
    padding: 4px; border-radius: 8px; transition: all 0.2s ease; flex-shrink: 0;
}
.nutre-toast-close:hover { background: var(--bg-main); color: var(--text-main); }
.nutre-toast-progress {
    position: absolute; bottom: 0; left: 0; height: 3px; background: var(--green-500);
    border-radius: 0 0 0 16px; animation: toastProgress 4s linear forwards;
}
.nutre-toast.toast-error .nutre-toast-progress { background: var(--coral); }
.nutre-toast.toast-warning .nutre-toast-progress { background: #F59E0B; }
.nutre-toast.toast-info .nutre-toast-progress { background: #3B82F6; }
@keyframes toastSlideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastSlideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(120%); opacity: 0; } }
@keyframes toastProgress { from { width: 100%; } to { width: 0%; } }

/* ── Skeleton Loading ────────────────────── */
.skeleton {
    background: linear-gradient(90deg, #F0F0F0 25%, #E0E0E0 50%, #F0F0F0 75%);
    background-size: 200% 100%; animation: skeletonShimmer 1.5s ease-in-out infinite; border-radius: 8px;
}
.skeleton-row { display: flex; align-items: center; gap: 15px; padding: 1.5rem; border-bottom: 1px solid #F3F4F6; }
.skeleton-avatar { width: 36px; height: 36px; border-radius: 10px; }
.skeleton-line { height: 14px; border-radius: 6px; }
.skeleton-line.w-40 { width: 40%; } .skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-80 { width: 80%; } .skeleton-line.w-20 { width: 20%; }
.skeleton-line.short { width: 80px; }
@keyframes skeletonShimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ── Empty States ────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4rem 2rem; text-align: center; }
.empty-state-icon {
    width: 80px; height: 80px; background: var(--green-100); border-radius: 24px;
    display: flex; align-items: center; justify-content: center; margin-bottom: 1.5rem;
    color: var(--green-500); animation: emptyPulse 3s ease-in-out infinite;
}
.empty-state-title { font-family: 'DM Serif Display', serif; font-size: 20px; color: var(--green-900); margin-bottom: 8px; }
.empty-state-desc { font-size: 14px; color: var(--text-muted); max-width: 320px; line-height: 1.6; margin-bottom: 1.5rem; }
.empty-state .btn-3d { font-size: 12px; padding: 0.5em 1.2em; }
@keyframes emptyPulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(82,183,136,0.2); } 50% { transform: scale(1.05); box-shadow: 0 0 0 12px rgba(82,183,136,0); } }

/* ── Unified Async States ────────────────── */
.nutre-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    padding: 2.5rem 1.5rem;
    text-align: center;
}
.nutre-state.is-compact { min-height: 96px; padding: 1.25rem; }
.nutre-state-icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    margin-bottom: 14px;
    border-radius: 16px;
    background: var(--green-100);
    color: var(--green-600);
}
.nutre-state.is-compact .nutre-state-icon { width: 34px; height: 34px; margin-bottom: 9px; border-radius: 10px; }
.nutre-state-title { color: var(--green-900); font-size: 15px; font-weight: 750; line-height: 1.35; }
.nutre-state-description { max-width: 390px; margin-top: 5px; color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.nutre-state .btn { margin-top: 14px; }
.nutre-state-error .nutre-state-icon { background: #fef2f2; color: #b42318; }
.nutre-state-success .nutre-state-icon { background: var(--green-100); color: var(--green-700); }
.nutre-state-spinner,
.nutre-button-spinner {
    width: 18px;
    height: 18px;
    display: inline-block;
    flex: 0 0 auto;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .65s linear infinite;
}
.nutre-button-spinner { width: 14px; height: 14px; margin-right: 7px; vertical-align: -2px; }
@media (prefers-reduced-motion: reduce) {
    .nutre-state-spinner,
    .nutre-button-spinner { animation-duration: 1.4s; }
}

/* ── Nutritive Loader ────────────────────── */
.nutre-loading-overlay {
    position: fixed; inset: 0; background: rgba(255,255,255,0.95); backdrop-filter: blur(10px);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 9999; opacity: 0; visibility: hidden; transition: all 0.4s ease-in-out;
}
.nutre-loading-overlay.show { opacity: 1; visibility: visible; }
.nutre-loading-overlay:not(.show) { pointer-events: none !important; }
.loader-container { position: relative; width: 140px; height: 140px; }
.loader-center {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-family: 'DM Serif Display', serif; font-size: 42px; color: var(--green-900);
    z-index: 2; animation: nutriPulse 1.8s ease-in-out infinite;
}
.loader-center span { color: var(--coral); }
.food-orbit { position: absolute; inset: 0; width: 100%; height: 100%; animation: nutriRotate 6s linear infinite; }
.food-item { position: absolute; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1)); }
.food-item svg { width: 100%; height: 100%; }
.f1 { top: -10px; left: 50%; transform: translateX(-50%); }
.f2 { top: 50%; right: -10px; transform: translateY(-50%); }
.f3 { bottom: -10px; left: 50%; transform: translateX(-50%); }
.f4 { top: 50%; left: -10px; transform: translateY(-50%); }
@keyframes nutriRotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes nutriPulse { 0%, 100% { transform: scale(1); opacity: 1; filter: blur(0); } 50% { transform: scale(0.85); opacity: 0.8; filter: blur(1px); } }
.loading-text { margin-top: 2.5rem; font-weight: 700; color: var(--green-900); letter-spacing: 0.2em; text-transform: uppercase; font-size: 13px; animation: textFade 1.5s ease-in-out infinite alternate; }
@keyframes textFade { from { opacity: 0.4; transform: translateY(0); } to { opacity: 1; transform: translateY(-3px); } }

/* ── Toggle Switches ─────────────────────── */
.switch { position: relative; display: inline-block; cursor: pointer; transition: background 0.3s ease; }
.switch::after { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.switch[style*="var(--green-500)"]::after { left: 18px; }

/* ── Timeline & Logs ─────────────────────── */
.module-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.module-title { font-family: 'DM Serif Display', serif; font-size: 24px; color: var(--green-900); }

.timeline-container { position: relative; padding-left: 2rem; border-left: 2px solid var(--border); margin-left: 1rem; }
.timeline-item { position: relative; margin-bottom: 2.5rem; }
.timeline-item::before { content: ''; position: absolute; left: calc(-2rem - 6px); top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--green-500); border: 2px solid #fff; box-shadow: 0 0 0 4px var(--green-100); }
.timeline-date { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 8px; display: block; }
.timeline-content { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem; box-shadow: var(--shadow-sm); transition: var(--transition); }
.timeline-content:hover { transform: translateX(5px); border-color: var(--green-200); box-shadow: var(--shadow-md); }
.timeline-title { font-weight: 700; color: var(--green-900); margin-bottom: 8px; font-size: 15px; }
.timeline-body { color: var(--text-muted); font-size: 14px; line-height: 1.6; }

/* ── Responsive Components ───────────────── */
@media (max-width: 600px) {
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .field.full { grid-column: auto; }
    .modal { padding: 1.5rem; }
    .modal-footer { flex-direction: column; }
}

/* Modern standardization layer */
.btn,
.btn-submit,
.btn-google,
.btn-back,
.btn-3d,
button.btn,
a.btn {
    min-height: 40px;
    border-radius: var(--radius-md);
    text-transform: none;
    letter-spacing: 0;
}

.btn,
.btn.primary,
.btn-submit,
.btn-3d {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--green-700);
    color: #fff !important;
    border: 1px solid var(--green-700);
    box-shadow: none;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.btn:hover,
.btn.primary:hover,
.btn-submit:hover,
.btn-3d:hover {
    background: var(--green-900);
    border-color: var(--green-900);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
    filter: none;
}

.btn:active,
.btn-submit:active,
.btn-3d:active {
    transform: translateY(0);
}

.btn-3d::after {
    display: none;
}

.btn.secondary,
.btn-back,
.btn-google {
    background: var(--bg-surface);
    color: var(--green-900) !important;
    border: 1px solid var(--border);
    box-shadow: none;
}

.btn.secondary:hover,
.btn-back:hover,
.btn-google:hover {
    background: var(--green-50);
    border-color: var(--green-500);
    color: var(--green-900) !important;
}

.btn.danger,
.btn-icon.danger {
    color: #fff !important;
    background: var(--danger);
    border-color: var(--danger);
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
}

.btn-icon:hover {
    background: var(--green-50);
    border-color: var(--border);
}

.card,
.data-card,
.stat-card,
.timeline-content,
.data-stat-card,
.plan-card,
.meal-card,
.modal,
.modal-content {
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.card:hover,
.stat-card:hover,
.timeline-content:hover,
.data-stat-card:hover {
    transform: none;
    box-shadow: var(--shadow-md);
}

.field label,
label {
    color: var(--text-main);
    text-transform: none;
    letter-spacing: 0;
}

input,
select,
textarea,
.field-wrap input,
.field-wrap select,
.field-wrap textarea,
.field input:not(.field-wrap input),
.field select:not(.field-wrap select),
.field textarea:not(.field-wrap textarea) {
    border-radius: var(--radius-md);
    border-color: var(--border);
    min-height: 42px;
}

input:focus,
select:focus,
textarea:focus,
.field-wrap input:focus,
.field-wrap select:focus,
.field-wrap textarea:focus {
    border-color: var(--green-500);
    box-shadow: var(--focus-ring);
}

select,
.nutre-select,
.input-modern {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2366736e' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding: 0 32px 0 12px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
    min-height: 38px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
select:focus-visible,
.nutre-select:focus-visible,
.input-modern:focus-visible {
    outline: none;
    border-color: var(--primary, #17634e);
    box-shadow: 0 0 0 3px rgba(23, 99, 78, 0.12);
}

.modal-header {
    margin-bottom: 1.25rem;
}

.modal-header h3,
.module-title,
.section-title,
.welcome-title,
.form-title {
    letter-spacing: 0;
}

.badge {
    border-radius: var(--radius-sm);
    text-transform: none;
    letter-spacing: 0;
}

.empty-state {
    min-height: 280px;
}

/* ── Cards de Tipo de Perfil (Nutricionista / Estudante) ── */
.profile-type-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.profile-type-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1.5px solid var(--border, #e5e7eb);
    background: var(--bg-surface, #ffffff);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.profile-type-card:hover {
    border-color: #9ca3af;
    background: #f9fafb;
    transform: translateY(-1px);
}

.profile-type-card.selected {
    border-color: #111827;
    background: #e5e7eb;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
}

.profile-type-card .card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: #111827;
    flex-shrink: 0;
}

.profile-type-card .card-content {
    flex: 1;
    min-width: 0;
}

.profile-type-card .card-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 2px 0;
    display: block;
}

.profile-type-card .card-desc {
    font-size: 12.5px;
    color: #4b5563;
    margin: 0;
    line-height: 1.35;
    display: block;
}

.profile-type-card .card-radio {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    background: #ffffff;
}

.profile-type-card.selected .card-radio {
    border-color: #111827;
    border-width: 2px;
}

.profile-type-card .card-radio-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: transparent;
    transition: background 0.2s ease;
}

.profile-type-card.selected .card-radio-dot {
    background: #111827;
}

/* Tema escuro */
[data-theme="dark"] .profile-type-card {
    background: #1f2937;
    border-color: #374151;
}
[data-theme="dark"] .profile-type-card.selected {
    background: #374151;
    border-color: #f3f4f6;
}
[data-theme="dark"] .profile-type-card .card-title {
    color: #f3f4f6;
}
[data-theme="dark"] .profile-type-card .card-desc {
    color: #9ca3af;
}
[data-theme="dark"] .profile-type-card .card-icon {
    color: #f3f4f6;
}
[data-theme="dark"] .profile-type-card.selected .card-radio {
    border-color: #f3f4f6;
}
[data-theme="dark"] .profile-type-card.selected .card-radio-dot {
    background: #f3f4f6;
}

