/* Chat styles for BYO-Me Assistant
   Uses design tokens from design-tokens.css */

/* Diary Button - Prominent styled button */
.btn-diary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color, #8B0000) 0%, var(--secondary-color, #DC143C) 100%);
    color: white !important;
    border: none;
    border-radius: 25px;
    padding: 0.5rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 3px 8px rgba(139, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.btn-diary:hover {
    background: linear-gradient(135deg, var(--secondary-color, #DC143C) 0%, var(--primary-color, #8B0000) 100%);
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(139, 0, 0, 0.4);
}

.btn-diary:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(139, 0, 0, 0.3);
}

.btn-diary i {
    font-size: 1.1rem;
}

/* Mobile: icon only */
@media (max-width: 575.98px) {
    .btn-diary {
        padding: 0.6rem;
        border-radius: 50%;
        width: 42px;
        height: 42px;
        justify-content: center;
    }

    .btn-diary i {
        font-size: 1.2rem;
    }
}

/* Chat container - uses viewport height for reliable sizing */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px); /* viewport minus navbar height */
    background-color: var(--gray-50, #f9fafb);
}

/* Chat header */
.chat-header {
    background-color: white;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    padding: 1rem 0;
    flex-shrink: 0;
}

/* Chat messages area */
.chat-messages {
    flex: 1 1 0;
    overflow-y: auto;
    padding: 2rem 0;
    background-color: var(--gray-50, #f9fafb);
    min-height: 0; /* Important: allows flex item to shrink below content size */
}

.messages-list {
    max-width: 800px;
    margin: 0 auto;
}

/* Message styles */
.message {
    display: flex;
    margin-bottom: 1.5rem;
    animation: messageSlideIn 0.3s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

/* Assistant avatar */
.message.assistant .message-avatar {
    background-color: #fff;
    border: 1px solid var(--gray-200, #e5e7eb);
    padding: 2px;
    width: 52px;
    height: 52px;
}

.message.assistant .message-avatar img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

/* User avatar - pomegranate red theme */
.message.user .message-avatar {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(139, 0, 0, 0.3);
}

.message.user .message-avatar i {
    font-size: 1rem;
}

.message-content {
    background-color: white;
    border-radius: var(--radius-2xl, 18px);
    padding: var(--space-4, 1rem) var(--space-5, 1.25rem);
    box-shadow: var(--shadow-xs, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
    width: fit-content;
    max-width: 70%;
    flex-shrink: 0;
    word-break: normal;
}

/* Override messaging.css .message-bubble inside chat context */
.message .message-bubble {
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: normal;
}

.message.user .message-bubble {
    white-space: pre-wrap;
}

.message.user {
    flex-direction: row-reverse;
}

.message.user .message-avatar {
    margin-right: 0;
    margin-left: 0.75rem;
}

.message.user .message-content {
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    border: 1px solid var(--gray-200, #e5e7eb);
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin-bottom: 0.5rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Markdown content styling */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child,
.message-content h4:first-child,
.message-content h5:first-child,
.message-content h6:first-child {
    margin-top: 0;
}

.message-content ul,
.message-content ol {
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
}

.message-content li {
    margin-bottom: 0.25rem;
}

.message-content code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
    color: #d63384;
}

.message.user .message-content code {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.message-content pre {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin-bottom: 0.5rem;
}

.message.user .message-content pre {
    background-color: rgba(0, 0, 0, 0.1);
}

.message-content pre code {
    background-color: transparent;
    padding: 0;
    color: inherit;
}

.message-content blockquote {
    border-left: 4px solid #dee2e6;
    padding-left: 1rem;
    margin-left: 0;
    margin-right: 0;
    color: #6c757d;
}

.message.user .message-content blockquote {
    border-left-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.9);
}

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

/* Chat input */
.chat-input-container {
    background-color: white;
    border-top: 1px solid var(--gray-200, #e5e7eb);
    padding: 0.5rem 0;
    flex-shrink: 0;
}

.chat-form {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

/* Unified two-row layout for all screen sizes */
.chat-form .input-group {
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.1));
    border-radius: var(--radius-xl, 12px);
    overflow: hidden;
    flex-wrap: wrap;
}

.chat-form .input-group .form-control {
    order: 1;
    width: 100%;
    flex: 1 1 100%;
    border: none;
    border-radius: 12px 12px 0 0 !important;
    border-bottom: 1px solid #dee2e6;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.5;
}

.chat-form .form-control:focus {
    box-shadow: none;
    border-color: transparent;
}

/* Button row - unified styles */
.chat-form .input-group .btn {
    order: 2;
    flex: 1 1 auto;
    border: none;
    border-radius: 0 !important;
    padding: 0.75rem 1rem;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-form .input-group .btn i {
    font-size: 1.2rem;
}

/* Button order: image (left), voice, send (right) */
.chat-form .input-group #imageButton {
    order: 2;
    border-bottom-left-radius: 12px !important;
}

.chat-form .input-group #voiceButton {
    order: 3;
}

.chat-form .input-group #sendButton {
    order: 4;
    border-bottom-right-radius: 12px !important;
}

/* When no imageButton exists (profiling page), voiceButton gets left radius */
.chat-form .input-group:not(:has(#imageButton)) #voiceButton,
.chat-form-no-image .input-group #voiceButton {
    border-bottom-left-radius: 12px !important;
}

/* Button separators */
.chat-form .input-group .btn + .btn {
    border-left: 1px solid #dee2e6;
}

/* Image button - colored background (crimson from palette) */
.chat-form .btn-image {
    background-color: var(--secondary-color);
    color: white;
}

.chat-form .btn-image:hover {
    background-color: var(--accent-color);
    color: white;
}

.chat-form .btn-image.active {
    background-color: var(--primary-color);
    color: white;
}

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

.chat-form .btn-secondary {
    background-color: #6c757d;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        height: calc(100vh - 50px); /* Smaller navbar on mobile */
    }

    .chat-messages {
        padding: 1rem 0;
    }

    .message-content {
        max-width: 85%;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        margin-right: 0.75rem;
    }

    .message.user .message-avatar {
        margin-left: 0.75rem;
    }

    .chat-form .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .chat-input-container {
        padding: 0.25rem 0;
    }
}

/* Mobile-specific adjustments */
@media (max-width: 576px) {
    .chat-header {
        padding: 0.75rem 0;
    }

    .chat-header h5 {
        font-size: 1.1rem;
    }

    .chat-header small {
        font-size: 0.75rem;
    }

    .chat-messages {
        padding: 0.75rem 0;
    }

    .message {
        margin-bottom: 0.75rem;
    }

    .message-content {
        padding: 0.625rem 0.875rem;
        font-size: 0.9rem;
    }

    .message-avatar {
        width: 30px;
        height: 30px;
        margin-right: 0.5rem;
    }

    .message.user .message-avatar {
        margin-left: 0.5rem;
        margin-right: 0;
    }

    .btn {
        padding: 0.375rem 0.75rem;
    }
}

/* Typing indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: var(--gray-50, #f9fafb);
    border-radius: var(--radius-full, 9999px);
    margin: 0.5rem 0;
    max-width: fit-content;
}

.typing-indicator i {
    color: var(--primary-color, #8B0000);
    font-size: 1.2rem;
}

.typing-indicator .dots {
    display: flex;
    align-items: center;
    gap: 3px;
}

.typing-indicator .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #8B0000;
    opacity: 0.3;
    animation: typing 1.4s infinite;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.3;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Voice recording styles — smooth pulse */
.recording {
    animation: pulse 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(220, 20, 60, 0.5);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(220, 20, 60, 0);
    }
}

/* Inline image preview inside a user message bubble */
.message-image-preview {
    display: block;
    max-width: 100%;
    max-height: 280px;
    width: auto;
    height: auto;
    border-radius: 8px;
    object-fit: cover;
    cursor: zoom-in;
}

/* Image attachment styles */
.image-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    font-size: 0.9rem;
    color: #6c757d;
}

.message.user .image-indicator {
    background-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

.image-indicator i {
    font-size: 1.1rem;
}

/* Image button active state (image attached) */
#imageButton.active {
    background-color: var(--primary-color) !important;
    color: white;
}

#imageButton.active:hover {
    background-color: var(--primary-color) !important;
    opacity: 0.9;
}

/* Image source selection menu (camera/gallery) */
.image-source-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    z-index: 1000;
    min-width: 160px;
}

.image-source-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: white;
    color: var(--text-dark, #333);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.image-source-option:hover {
    background-color: var(--gray-100, #f3f4f6);
}

.image-source-option:active {
    background-color: var(--gray-200, #e5e7eb);
}

.image-source-option i {
    font-size: 1.2rem;
    color: var(--secondary-color, #dc143c);
}

.image-source-option + .image-source-option {
    border-top: 1px solid #eee;
}

/* ============================================
   SSE Streaming Styles
   ============================================ */

/* Streaming message styles */
.message.assistant .message-bubble.streaming {
    background-color: white;
}

.streaming-content {
    display: inline;
}

/* Blinking cursor for streaming effect — thin bar style */
.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    vertical-align: text-bottom;
    margin-left: 1px;
    background-color: var(--primary-color, #8B0000);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* Tool execution indicator — pill badge style */
.tool-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2, 0.5rem);
    padding: var(--space-2, 0.5rem) var(--space-4, 1rem);
    background-color: var(--gray-100, #f3f4f6);
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: var(--radius-full, 9999px);
    margin: var(--space-2, 0.5rem) 0;
    animation: fadeInSlide 0.3s ease;
}

.tool-indicator .tool-icon {
    color: var(--primary-color, #8B0000);
    font-size: 0.9rem;
}

.tool-indicator .tool-text {
    color: var(--gray-600, #4b5563);
    font-size: var(--text-xs, 0.75rem);
    font-weight: var(--font-medium, 500);
}

/* Spinning animation for icons */
.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Progress indicator - pill badge style */
.progress-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2, 0.5rem);
    padding: var(--space-2, 0.5rem) var(--space-4, 1rem);
    background-color: var(--gray-50, #f9fafb);
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: var(--radius-full, 9999px);
    margin: var(--space-2, 0.5rem) 0;
    animation: fadeInSlide 0.3s ease;
}

.progress-indicator .progress-icon {
    color: var(--primary-color, #8B0000);
    font-size: 1rem;
    display: flex;
    align-items: center;
}

.progress-indicator .progress-text {
    color: var(--gray-700, #374151);
    font-size: var(--text-xs, 0.75rem);
    font-weight: var(--font-medium, 500);
}

.progress-indicator .progress-step {
    color: var(--gray-400, #9ca3af);
    font-size: var(--text-xs, 0.75rem);
    font-weight: var(--font-regular, 400);
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Message typing indicator for streaming (dots) */
.message.assistant.typing .typing-indicator {
    background-color: #f8f9fa;
    padding: 0.5rem 1rem;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.message.assistant.typing .typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary-color, #8B0000);
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.message.assistant.typing .typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.message.assistant.typing .typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive adjustments for streaming */
@media (max-width: 768px) {
    .tool-indicator,
    .progress-indicator {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .tool-indicator .tool-icon,
    .progress-indicator .progress-icon {
        font-size: 1rem;
    }

    .progress-indicator .progress-text {
        font-size: 0.85rem;
    }
}

/* ============================================
   Food Diary Overlay Styles
   ============================================ */

/* Full-screen overlay - slides in from right */
.diary-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-50, #f9fafb);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    animation: slideInFromRight 0.3s var(--ease-out, ease-out);
}

.diary-overlay.closing {
    animation: slideOutToRight 0.3s ease-in forwards;
}

@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideOutToRight {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(100%);
    }
}

/* Header with navigation */
.diary-header {
    background-color: white;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-xs, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
    /* Safe area for notched devices */
    padding-top: max(0.875rem, env(safe-area-inset-top));
}

.diary-header .back-btn,
.diary-header .close-btn {
    background: none;
    border: none;
    color: var(--primary-color, #8B0000);
    font-size: 1.25rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Touch-friendly size */
    min-width: 44px;
    min-height: 44px;
}

.diary-header .back-btn:hover,
.diary-header .close-btn:hover {
    background-color: rgba(139, 0, 0, 0.1);
}

.diary-header .back-btn:active,
.diary-header .close-btn:active {
    background-color: rgba(139, 0, 0, 0.2);
}

/* Day navigation arrows (prev/next day) */
.diary-header .day-nav-btn {
    background: none;
    border: none;
    color: var(--primary-color, #8B0000);
    font-size: 1.1rem;
    padding: 0.375rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.diary-header .day-nav-btn:hover {
    background-color: rgba(139, 0, 0, 0.1);
}

.diary-header .day-nav-btn:active {
    background-color: rgba(139, 0, 0, 0.2);
}

.diary-header .day-nav-btn:disabled {
    color: #ccc;
    cursor: default;
    background: none;
}

.diary-header .diary-title {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-dark, #333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Scrollable content area */
.diary-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    /* Safe area for bottom */
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

/* List items - touch-friendly with good tap targets */
.diary-list-item {
    background: white;
    border-radius: var(--radius-xl, 12px);
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-xs, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
    cursor: pointer;
    transition: transform var(--duration-fast, 0.15s) ease, box-shadow var(--duration-fast, 0.15s) ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Touch-friendly min height */
    min-height: 80px;
}

.diary-list-item:hover {
    box-shadow: var(--shadow-md, 0 2px 8px rgba(0, 0, 0, 0.15));
}

.diary-list-item:active {
    transform: scale(0.98);
}

/* Item main content */
.diary-item-main {
    flex: 1;
    min-width: 0;
}

.diary-item-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-dark, #333);
    margin-bottom: 0.25rem;
}

.diary-item-subtitle {
    font-size: 0.85rem;
    color: var(--text-light, #666);
    margin-bottom: 0.5rem;
}

.diary-item-meta {
    font-size: 0.75rem;
    color: #adb5bd;
}

/* Nutrients display - horizontal layout */
.diary-nutrients {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.diary-nutrient {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 45px;
}

.diary-nutrient-value {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary-color, #8B0000);
}

.diary-nutrient-label {
    font-size: 0.7rem;
    color: var(--text-light, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Chevron for navigation hint */
.diary-item-chevron {
    color: #adb5bd;
    font-size: 1.2rem;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

/* Meal photo thumbnail */
.meal-photo-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.meal-photo-thumb:hover {
    transform: scale(1.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Meal photo lightbox / carousel */
.meal-photo-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.meal-photo-lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
}

.meal-photo-lightbox-content {
    position: relative;
    width: 95vw;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.meal-photo-lightbox-content img {
    max-width: 95vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    user-select: none;
    -webkit-user-drag: none;
}

.meal-photo-lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s, background-color 0.15s;
    z-index: 2;
}

.meal-photo-lightbox-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.7);
}

/* Carousel track */
.carousel-track {
    display: flex;
    transition: transform 0.3s ease;
    will-change: transform;
}

.carousel-track.dragging {
    transition: none;
}

.carousel-slide {
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.carousel-slide img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    user-select: none;
    -webkit-user-drag: none;
}

/* Carousel navigation arrows */
.carousel-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    opacity: 0.7;
    transition: opacity 0.15s, background-color 0.15s;
    z-index: 2;
}

.carousel-nav-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.7);
}

.carousel-nav-btn.prev {
    left: 12px;
}

.carousel-nav-btn.next {
    right: 12px;
}

/* Carousel counter */
.carousel-counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 14px;
    border-radius: 12px;
    z-index: 2;
    letter-spacing: 0.5px;
}

/* Carousel loading spinner */
.carousel-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 200px;
    color: rgba(255, 255, 255, 0.6);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .carousel-track {
        transition: none;
    }
}

@media (max-width: 768px) {
    .carousel-nav-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .carousel-nav-btn.prev {
        left: 6px;
    }

    .carousel-nav-btn.next {
        right: 6px;
    }

    .carousel-slide img {
        max-width: 95vw;
        max-height: 80vh;
        border-radius: 4px;
    }
}

/* Load more button */
.diary-load-more {
    text-align: center;
    padding: 1rem;
}

.diary-load-more .btn {
    min-width: 150px;
}

/* Empty state */
.diary-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light, #666);
}

.diary-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
    color: var(--primary-color, #8B0000);
}

.diary-empty h6 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.diary-empty p {
    font-size: 0.9rem;
    margin: 0;
}

/* Loading spinner */
.diary-loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem 1rem;
    gap: 1rem;
}

.diary-loading .spinner-border {
    width: 2.5rem;
    height: 2.5rem;
}

.diary-loading-text {
    color: var(--text-light, #666);
    font-size: 0.9rem;
}

/* Error state */
.diary-error {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light, #666);
}

.diary-error i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #dc3545;
}

.diary-error .btn {
    margin-top: 1rem;
}

/* Ingredient-specific styles (smaller items) */
.diary-list-item.ingredient-item {
    min-height: 60px;
    padding: 0.75rem 1rem;
}

.ingredient-item .diary-item-title {
    font-size: 0.95rem;
}

.ingredient-item .diary-nutrients {
    margin-top: 0.25rem;
}

.ingredient-item .diary-nutrient {
    min-width: 40px;
}

.ingredient-item .diary-nutrient-value {
    font-size: 0.85rem;
}

/* ============================================
   Unmatched Ingredient Styles
   ============================================ */

/* Unmatched ingredient card styling */
.diary-list-item.unmatched-ingredient {
    border-left: 3px solid var(--bs-warning, #ffc107);
    background: linear-gradient(90deg, rgba(255, 193, 7, 0.08) 0%, white 25%);
}

.diary-list-item.unmatched-ingredient:hover {
    background: linear-gradient(90deg, rgba(255, 193, 7, 0.12) 0%, white 25%);
}

/* Unmatched section header */
.unmatched-section-header {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--bs-warning, #ffc107);
}

.unmatched-section-header h6 {
    color: var(--bs-warning, #ffc107);
    font-weight: 600;
}

/* Unmatched nutrients with "?" values */
.unmatched-nutrients .diary-nutrient-value {
    color: var(--bs-secondary, #6c757d);
    font-style: italic;
}

/* Delete button for unmatched ingredients */
.btn-delete-unmatched {
    background: none;
    border: none;
    color: var(--bs-danger, #dc3545);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.15s;
    margin-left: auto;
}

.btn-delete-unmatched:hover {
    background-color: rgba(220, 53, 69, 0.1);
}

/* Unmatched status icon in title */
.unmatched-status-icon {
    margin-right: 0.35rem;
    font-size: 0.85em;
}

.unmatched-status-icon.bi-hourglass-split {
    color: var(--bs-warning, #ffc107);
    animation: gentle-pulse 2s ease-in-out infinite;
}

.unmatched-status-icon.bi-database-add {
    color: var(--bs-info, #0dcaf0);
}

.unmatched-status-icon.bi-dash-circle {
    color: var(--bs-secondary, #6c757d);
}

@keyframes gentle-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Warning banner for underestimated energy due to unmatched ingredients */
.energy-bar-unmatched-warning {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
    color: var(--bs-warning-text-emphasis, #664d03);
    background-color: var(--bs-warning-bg-subtle, #fff3cd);
    border: 1px solid var(--bs-warning-border-subtle, #ffe69c);
    border-radius: 0.375rem;
}

.energy-bar-unmatched-warning i {
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* "Report missing ingredient" option in autocomplete */
.autocomplete-item.report-missing-option {
    border-top: 1px solid var(--bs-border-color, #dee2e6);
    color: var(--bs-primary, #0d6efd);
    font-weight: 500;
    margin-top: 0.25rem;
    padding-top: 0.75rem;
}

.autocomplete-item.report-missing-option:hover {
    background-color: var(--bs-primary, #0d6efd);
    color: white;
}

.autocomplete-item.report-missing-option i {
    opacity: 0.8;
}

/* Quantity badge */
.diary-quantity {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background-color: rgba(139, 0, 0, 0.1);
    color: var(--primary-color, #8B0000);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Section header for sub-lists */
.diary-section-header {
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
}

.diary-section-header h6 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

/* Extended Nutrients - Expand button */
.btn-expand-nutrients {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border: none;
    background: rgba(139, 0, 0, 0.15);
    color: var(--primary-color, #8B0000);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-expand-nutrients:hover,
.btn-expand-nutrients:focus {
    background: rgba(139, 0, 0, 0.25);
    outline: none;
}

.btn-expand-nutrients:active {
    background: rgba(139, 0, 0, 0.35);
    transform: scale(0.95);
}

.btn-expand-nutrients i {
    font-size: 0.9rem;
    pointer-events: none;
}

/* Extended Nutrients Container */
.extended-nutrients-container {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed rgba(139, 0, 0, 0.2);
    animation: slideDownSmall 0.3s ease;
}

@keyframes slideDownSmall {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Nutrient Category */
.nutrient-category {
    margin-bottom: 0.75rem;
}

.nutrient-category:last-child {
    margin-bottom: 0;
}

.nutrient-category-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color, #8B0000);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid rgba(139, 0, 0, 0.1);
}

.nutrient-category-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.25rem 1rem;
}

.nutrient-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    font-size: 0.8rem;
}

.nutrient-name {
    color: var(--text-dark, #333);
}

.nutrient-value {
    font-weight: 500;
    color: var(--text-light, #666);
    text-align: right;
    white-space: nowrap;
}

/* Responsive adjustments for small screens */
@media (max-width: 576px) {
    /* Extended nutrients */
    .nutrient-category-items {
        grid-template-columns: 1fr;
    }

    .nutrient-row {
        font-size: 0.75rem;
    }

    /* Keep button large on mobile for better touch target */
    .btn-expand-nutrients {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }

    .btn-expand-nutrients i {
        font-size: 1rem;
    }

    /* Diary layout */
    .diary-header {
        padding: 0.75rem;
    }

    .diary-header .diary-title {
        font-size: 1rem;
    }

    .diary-header .day-nav-btn {
        font-size: 1rem;
        padding: 0.25rem;
    }

    .diary-content {
        padding: 0.75rem;
    }

    .diary-list-item {
        padding: 0.875rem;
    }

    .diary-nutrients {
        gap: 0.5rem;
    }

    .diary-nutrient {
        min-width: 40px;
    }

    .diary-nutrient-value {
        font-size: 0.85rem;
    }

    .diary-nutrient-label {
        font-size: 0.65rem;
    }
}

/* ============================================
   Food Diary Calendar Styles
   ============================================ */

.diary-calendar {
    max-width: 400px;
    margin: 0 auto;
    padding: 1rem;
}

/* Calendar header with navigation */
.diary-calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding: 0 0.5rem;
}

.diary-calendar-month-year {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
}

.diary-calendar-month {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark, #333);
}

.diary-calendar-year {
    font-size: 0.875rem;
    color: var(--text-light, #666);
}

.diary-calendar-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: rgba(139, 0, 0, 0.1);
    color: var(--primary-color, #8B0000);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.diary-calendar-nav:hover:not(.disabled) {
    background: rgba(139, 0, 0, 0.2);
}

.diary-calendar-nav:active:not(.disabled) {
    background: rgba(139, 0, 0, 0.3);
    transform: scale(0.95);
}

.diary-calendar-nav.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.diary-calendar-nav i {
    font-size: 1.1rem;
}

/* Weekday headers */
.diary-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 0.5rem;
}

.diary-calendar-weekday {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.5rem 0;
}

/* Days grid */
.diary-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.diary-calendar-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    aspect-ratio: 1;
    min-height: 44px;
    border-radius: 50%;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-dark, #333);
    background: white;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    border: 2px solid transparent;
}

.diary-calendar-day:hover:not(.disabled):not(.other-month) {
    background: rgba(139, 0, 0, 0.1);
}

.diary-calendar-day:active:not(.disabled):not(.other-month) {
    transform: scale(0.95);
}

/* Today highlight */
.diary-calendar-day.today {
    background: rgba(139, 0, 0, 0.15);
    color: var(--primary-color, #8B0000);
    font-weight: 700;
}

/* Selected day */
.diary-calendar-day.selected {
    background: var(--primary-color, #8B0000);
    color: white;
    font-weight: 600;
}

.diary-calendar-day.selected.today {
    background: var(--primary-color, #8B0000);
    color: white;
}

/* Disabled (future) days */
.diary-calendar-day.disabled,
.diary-calendar-day.future {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Other month days (grayed out) */
.diary-calendar-day.other-month {
    color: #ccc;
    background: transparent;
    cursor: default;
}

/* Calendar footer */
.diary-calendar-footer {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.diary-calendar-footer .btn-link {
    color: var(--primary-color, #8B0000);
    text-decoration: none;
    font-weight: 500;
}

.diary-calendar-footer .btn-link:hover {
    text-decoration: underline;
}

.diary-calendar-day-number {
    line-height: 1;
}

/* Entry indicators */
.diary-calendar-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: block;
}

.diary-calendar-indicator.empty {
    background: #e0e0e0;
    border: 1px solid #ccc;
}

.diary-calendar-indicator.partial {
    background: #ffc107;
    border: 1px solid #e0a800;
}

.diary-calendar-indicator.complete {
    background: #28a745;
    border: 1px solid #1e7e34;
}

/* Legend */
.diary-calendar-legend {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 8px;
    flex-wrap: wrap;
}

.diary-calendar-legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-light, #666);
}

.diary-calendar-legend-item .diary-calendar-indicator {
    width: 10px;
    height: 10px;
}

/* Responsive adjustments for calendar */
@media (max-width: 400px) {
    .diary-calendar {
        padding: 0.5rem;
    }

    .diary-calendar-day {
        min-height: 40px;
        font-size: 0.9rem;
    }

    .diary-calendar-month {
        font-size: 1.1rem;
    }

    .diary-calendar-nav {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }

    .diary-calendar-indicator {
        width: 6px;
        height: 6px;
    }

    .diary-calendar-legend {
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .diary-calendar-legend-item {
        font-size: 0.7rem;
    }

    .diary-calendar-legend-item .diary-calendar-indicator {
        width: 8px;
        height: 8px;
    }
}

/* ============================================
   Daily Summary Card Styles
   ============================================ */

.daily-summary-card {
    background: linear-gradient(135deg, #fff 0%, var(--gray-50, #f9fafb) 100%);
    border: 1px solid rgba(139, 0, 0, 0.15);
    border-radius: var(--radius-2xl, 16px);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(139, 0, 0, 0.08));
}

.summary-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color, #8B0000);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(139, 0, 0, 0.1);
}

.summary-title i {
    font-size: 1.2rem;
}

.summary-nutrients {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.summary-nutrient-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.summary-nutrient-row.main {
    border-bottom: 1px dashed rgba(0, 0, 0, 0.06);
}

.summary-nutrient-row.main:last-child {
    border-bottom: none;
}

.summary-nutrient-row .nutrient-label {
    font-size: 0.95rem;
    color: var(--text-dark, #333);
    font-weight: 500;
}

.summary-nutrient-row .nutrient-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-color, #8B0000);
}

/* Sub-nutrients (indented) */
.summary-sub-nutrients {
    padding-left: 1.25rem;
    margin-top: -0.25rem;
    margin-bottom: 0.25rem;
    border-left: 2px solid rgba(139, 0, 0, 0.15);
    margin-left: 0.5rem;
}

.summary-nutrient-row.sub {
    padding: 0.35rem 0;
}

.summary-nutrient-row.sub .nutrient-label {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-light, #666);
}

.summary-nutrient-row.sub .nutrient-value {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dark, #555);
}

/* Empty message */
.summary-empty-message {
    text-align: center;
    color: var(--text-light, #666);
    font-size: 0.9rem;
    padding: 1rem 0;
    font-style: italic;
}

/* Nutrient percentage display */
.nutrient-pct {
    color: #6c757d;
    font-size: 0.85em;
    font-weight: 400;
    margin-left: 4px;
}

/* Warning icon for nutrients exceeding thresholds */
.nutrient-warning {
    color: #dc3545;
    margin-left: 6px;
    font-size: 0.9em;
    cursor: help;
}

/* Clickable warning icons in daily summary */
.nutrient-warning.clickable-warning {
    cursor: pointer;
    transition: transform 0.15s ease, color 0.15s ease;
}
.nutrient-warning.clickable-warning:hover {
    transform: scale(1.25);
    color: #b02a37;
}
.nutrient-warning.clickable-warning:active {
    transform: scale(1.1);
}

/* ============================================
   Warning Drill-Down (dishes sorted by nutrient)
   ============================================ */

.warning-info-banner {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: #856404;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.warning-info-banner i {
    color: #e0a800;
    font-size: 1rem;
    flex-shrink: 0;
}

.warning-dish-item .diary-item-subtitle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.meal-type-badge {
    display: inline-block;
    background: rgba(139, 0, 0, 0.08);
    color: #8b0000;
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.warning-dish-quantity {
    font-size: 0.8rem;
    color: #666;
}

.warning-dish-nutrient-row {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    margin-top: 0.25rem;
}

.dish-nutrient-highlight {
    font-weight: 700;
    font-size: 0.95rem;
    color: #dc3545;
}

.dish-nutrient-label {
    font-size: 0.8rem;
    color: #888;
}

/* ============================================
   Energy Progress Bar (kcal vs TEE)
   ============================================ */

.energy-progress-section {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(139, 0, 0, 0.1);
}

.energy-progress-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light, #666);
    margin-bottom: 0.5rem;
}

.energy-bar-container {
    position: relative;
    margin-bottom: 0.4rem;
}

.energy-bar-track {
    position: relative;
    height: 12px;
    background: #e9ecef;
    border-radius: 6px;
    overflow: visible;
}

.energy-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.4s ease, background-color 0.3s ease;
}

/* Color variants */
.energy-bar--under .energy-bar-fill {
    background: linear-gradient(90deg, #4a90d9, #5ba3ec);
}
.energy-bar--good .energy-bar-fill {
    background: linear-gradient(90deg, #28a745, #34c759);
}
.energy-bar--over .energy-bar-fill {
    background: linear-gradient(90deg, #f0ad4e, #e89b20);
}
.energy-bar--excess .energy-bar-fill {
    background: linear-gradient(90deg, #dc3545, #c82333);
}

/* TEE marker - vertical line with dot */
.energy-bar-tee-marker {
    position: absolute;
    top: -3px;
    width: 2px;
    height: 18px;
    background: var(--primary-color, #8B0000);
    border-radius: 1px;
    transform: translateX(-1px);
    z-index: 2;
}

.energy-bar-tee-marker::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    width: 8px;
    height: 8px;
    background: var(--primary-color, #8B0000);
    border-radius: 50%;
}

/* Legend row - static layout below bar, never overlaps */
.energy-bar-legend-static {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.15rem 0.75rem;
    font-size: 0.8rem;
    margin-top: 0.35rem;
}

.energy-bar-legend-item--consumed {
    font-weight: 600;
    color: var(--text-dark, #333);
}

.energy-bar-legend-item--goal {
    font-weight: 500;
    color: var(--primary-color, #8B0000);
}

.energy-bar-legend-item--tee-secondary {
    font-size: 0.75rem;
    color: #999;
    font-weight: 400;
    width: 100%;
    text-align: right;
}

/* Contextual message */
.energy-bar-message {
    text-align: center;
    font-size: 0.8rem;
    margin-top: 0.3rem;
    color: var(--text-light, #666);
}

.energy-bar-message.energy-bar--under {
    color: #4a90d9;
}
.energy-bar-message.energy-bar--good {
    color: #28a745;
}
.energy-bar-message.energy-bar--over {
    color: #e89b20;
}
.energy-bar-message.energy-bar--excess {
    color: #dc3545;
}

/* Secondary TEE marker (when goal differs from TEE) */
.energy-bar-tee-marker--secondary {
    background: #999;
    opacity: 0.5;
    width: 1px;
    height: 14px;
    top: -1px;
}

.energy-bar-tee-marker--secondary::after {
    width: 6px;
    height: 6px;
    background: #999;
    left: -2.5px;
    top: -2px;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .daily-summary-card {
        padding: 1rem;
        border-radius: 12px;
    }

    .summary-title {
        font-size: 0.95rem;
    }

    .summary-nutrient-row .nutrient-label,
    .summary-nutrient-row .nutrient-value {
        font-size: 0.9rem;
    }

    .summary-nutrient-row.sub .nutrient-label,
    .summary-nutrient-row.sub .nutrient-value {
        font-size: 0.8rem;
    }

    .summary-sub-nutrients {
        padding-left: 1rem;
    }
}

/* ============================================
   Inline Quantity Editing Styles
   ============================================ */

/* Editable quantity badge */
.diary-quantity.editable {
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    user-select: none;
}

.diary-quantity.editable:hover {
    background-color: rgba(139, 0, 0, 0.2);
    transform: scale(1.02);
}

.diary-quantity.editable:active {
    transform: scale(0.98);
}

/* Edit mode input */
.diary-quantity-input {
    width: 70px;
    border: 2px solid var(--primary-color, #8B0000);
    border-radius: 6px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.25rem 0.375rem;
    background-color: white;
    color: var(--primary-color, #8B0000);
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

/* Hide number spinner */
.diary-quantity-input::-webkit-outer-spin-button,
.diary-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.diary-quantity-input:focus {
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.15);
}

/* Saving state */
.diary-quantity.saving {
    opacity: 0.6;
    pointer-events: none;
}

.diary-quantity.saving::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 4px;
    border: 2px solid var(--primary-color, #8B0000);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Error state */
.diary-quantity.error {
    background-color: rgba(220, 53, 69, 0.15);
    border: 1px solid #dc3545;
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Editable meal time badge */
.diary-time {
    display: inline-flex;
    align-items: center;
    background-color: rgba(139, 0, 0, 0.1);
    color: var(--primary-color, #8B0000);
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Meal type icon (clickable to change type) */
.diary-meal-type-icon {
    cursor: pointer;
    color: #8B0000;
    font-size: 1.25rem;
    padding: 6px;
    margin-right: 4px;
    margin-left: -6px;
    border-radius: 50%;
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.diary-meal-type-icon:hover {
    color: #DC143C;
    background-color: rgba(139, 0, 0, 0.08);
}

.diary-meal-type-icon:active {
    transform: scale(0.92);
    background-color: rgba(139, 0, 0, 0.15);
}

/* Current type indicator in change modal */
.meal-type-option.current {
    border-color: #8B0000;
    background-color: rgba(139, 0, 0, 0.05);
}

.diary-time.editable {
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    user-select: none;
}

.diary-time.editable:hover {
    background-color: rgba(139, 0, 0, 0.2);
    transform: scale(1.02);
}

.diary-time.editable:active {
    transform: scale(0.98);
}

/* Time edit mode input */
.diary-time-input {
    width: 100px;
    border: 2px solid var(--primary-color, #8B0000);
    border-radius: 6px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.25rem 0.375rem;
    background-color: white;
    color: var(--primary-color, #8B0000);
    outline: none;
}

.diary-time-input:focus {
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.15);
}

/* Time saving state */
.diary-time.saving {
    opacity: 0.6;
    pointer-events: none;
}

.diary-time.saving::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 4px;
    border: 2px solid var(--primary-color, #8B0000);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Time error state */
.diary-time.error {
    background-color: rgba(220, 53, 69, 0.15);
    border: 1px solid #dc3545;
    animation: shake 0.3s ease;
}

/* Editable dish name */
.dish-name-editable {
    cursor: pointer;
    transition: color 0.2s;
    border-bottom: 1px dashed transparent;
}

.dish-name-editable:hover {
    color: var(--primary-color, #8B0000);
    border-bottom-color: var(--primary-color, #8B0000);
}

.dish-name-editable.editing {
    border-bottom: none;
}

/* Dish name edit input */
.diary-dish-name-input {
    width: 100%;
    border: 2px solid var(--primary-color, #8B0000);
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.2rem 0.375rem;
    background-color: white;
    color: #333;
    outline: none;
    box-sizing: border-box;
}

.diary-dish-name-input:focus {
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.15);
}

/* Dish name saving state */
.dish-name-editable.saving {
    opacity: 0.6;
    pointer-events: none;
}

/* Dish name error state */
.dish-name-editable.error {
    color: #dc3545;
    animation: shake 0.3s ease;
}

/* Toast notification for errors */
.diary-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    animation: toastIn 0.3s ease;
}

.diary-toast.error {
    background-color: #dc3545;
}

.diary-toast.success {
    background-color: #28a745;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .diary-quantity-input {
        width: 60px;
        font-size: 0.8rem;
        padding: 0.2rem 0.3rem;
    }

    .diary-time-input {
        width: 90px;
        font-size: 0.8rem;
        padding: 0.2rem 0.3rem;
    }

    .diary-toast {
        width: calc(100% - 2rem);
        left: 1rem;
        right: 1rem;
        transform: none;
        text-align: center;
    }
}

/* ============================================
   Edit Button Styles (Dish & Ingredient)
   ============================================ */

.btn-edit-dish,
.btn-edit-ingredient {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.btn-edit-dish:hover,
.btn-edit-ingredient:hover {
    background: rgba(13, 110, 253, 0.2);
}

.btn-edit-dish:active,
.btn-edit-ingredient:active {
    transform: scale(0.95);
}

.btn-edit-dish i,
.btn-edit-ingredient i {
    font-size: 1rem;
    pointer-events: none;
}

@media (max-width: 576px) {
    .btn-edit-dish,
    .btn-edit-ingredient {
        width: 44px;
        height: 44px;
    }

    .btn-edit-dish i,
    .btn-edit-ingredient i {
        font-size: 1.1rem;
    }
}

/* ============================================
   Delete Ingredient Button Styles
   ============================================ */

/* Delete Ingredient Button */
.btn-delete-ingredient {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.btn-delete-ingredient:hover {
    background: rgba(220, 53, 69, 0.2);
}

.btn-delete-ingredient:active {
    transform: scale(0.95);
}

.btn-delete-ingredient i {
    font-size: 1rem;
    pointer-events: none;
}

/* Deleting state (while API call in progress) */
.ingredient-item.deleting {
    opacity: 0.5;
    pointer-events: none;
}

/* Deleted animation (slide out) */
.ingredient-item.deleted {
    animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideOutRight {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Mobile touch target optimization */
@media (max-width: 576px) {
    .btn-delete-ingredient {
        width: 44px;
        height: 44px;
    }

    .btn-delete-ingredient i {
        font-size: 1.1rem;
    }
}

/* ============================================
   Delete Dish Button Styles
   ============================================ */

.btn-delete-dish {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 0.5rem;
    margin-right: 0.5rem;
}

.btn-delete-dish:hover {
    background: rgba(220, 53, 69, 0.2);
}

.btn-delete-dish:active {
    transform: scale(0.95);
}

.btn-delete-dish i {
    font-size: 1rem;
    pointer-events: none;
}

.diary-list-item.dish-item.deleting {
    opacity: 0.5;
    pointer-events: none;
}

.diary-list-item.dish-item.deleted {
    animation: slideOutRight 0.3s ease forwards;
}

@media (max-width: 576px) {
    .btn-delete-dish {
        width: 44px;
        height: 44px;
    }

    .btn-delete-dish i {
        font-size: 1.1rem;
    }
}

/* =============================================================================
   Delete Meal Button Styles
   ============================================================================= */

.btn-delete-meal {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--bs-danger, #dc3545);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    margin-right: 0.5rem;
}

.btn-delete-meal:hover {
    background: rgba(220, 53, 69, 0.2);
}

.btn-delete-meal:active {
    transform: scale(0.95);
}

.btn-delete-meal i {
    font-size: 1rem;
    pointer-events: none;
}

.diary-list-item.deleting {
    opacity: 0.5;
    pointer-events: none;
}

.diary-list-item.deleted {
    animation: slideOutRight 0.3s ease forwards;
}

@media (max-width: 576px) {
    .btn-delete-meal {
        width: 44px;
        height: 44px;
    }

    .btn-delete-meal i {
        font-size: 1.1rem;
    }
}

/* =============================================================================
   ADD DISH BUTTON AND MODAL
   ============================================================================= */

/* Add Dish Button Container */
.diary-add-dish-container {
    padding: 1rem;
    display: flex;
    justify-content: center;
}

/* Add Dish Button */
.btn-add-dish {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #8B0000 0%, #DC143C 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(139, 0, 0, 0.3);
}

.btn-add-dish:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(139, 0, 0, 0.4);
}

.btn-add-dish:active {
    transform: translateY(0);
}

.btn-add-dish i {
    font-size: 1.1rem;
}

/* Add Dish Modal */
.diary-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1060;
    padding: 1rem;
}

.diary-modal-content {
    background: white;
    border-radius: var(--radius-2xl, 16px);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow-xl, 0 10px 40px rgba(0, 0, 0, 0.2));
    animation: modalSlideIn 0.3s ease;
}

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

.diary-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #eee;
}

.diary-modal-header h5 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.diary-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease;
}

.diary-modal-close:hover {
    color: #333;
}

.diary-modal-body {
    padding: 1.25rem;
}

.diary-modal-body .form-label {
    font-weight: 500;
    color: #555;
    margin-bottom: 0.5rem;
}

.diary-modal-body .form-control {
    border-radius: 8px;
    border: 1px solid #ddd;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.diary-modal-body .form-control:focus {
    border-color: #8B0000;
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1);
    outline: none;
}

.diary-modal-body .form-control::placeholder {
    color: #aaa;
}

.diary-modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.25rem;
    border-top: 1px solid #eee;
}

.diary-modal-footer .btn {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.diary-modal-footer .btn-secondary {
    background: #f5f5f5;
    border: 1px solid #ddd;
    color: #666;
}

.diary-modal-footer .btn-secondary:hover {
    background: #eee;
}

.diary-modal-footer .btn-primary {
    background: linear-gradient(135deg, #8B0000 0%, #DC143C 100%);
    border: none;
    color: white;
}

.diary-modal-footer .btn-primary:hover:not(:disabled) {
    box-shadow: 0 3px 10px rgba(139, 0, 0, 0.3);
}

.diary-modal-footer .btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.diary-modal-footer .btn-loading {
    display: inline-flex;
    align-items: center;
}

/* Mobile: Full-width bottom sheet */
@media (max-width: 575.98px) {
    .diary-modal {
        padding: 0;
        align-items: flex-end;
    }

    .diary-modal-content {
        border-radius: 16px 16px 0 0;
        max-width: none;
        max-height: 85vh;
    }

    .diary-modal-footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }
}

/* =============================================================================
   ADD INGREDIENT BUTTON AND AUTOCOMPLETE
   ============================================================================= */

/* Add Ingredient Button Container */
.diary-add-ingredient-container {
    padding: 1rem;
    display: flex;
    justify-content: center;
}

/* Add Ingredient Button - Green to differentiate from Add Dish */
.btn-add-ingredient {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(40, 167, 69, 0.3);
}

.btn-add-ingredient:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

.btn-add-ingredient:active {
    transform: translateY(0);
}

.btn-add-ingredient i {
    font-size: 1.1rem;
}

/* Autocomplete Container */
.autocomplete-container {
    position: relative;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1070;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 250px;
    overflow-y: auto;
}

/* Autocomplete Item */
.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.15s ease;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: rgba(40, 167, 69, 0.08);
}

.autocomplete-item.active {
    background-color: rgba(40, 167, 69, 0.12);
}

.autocomplete-item-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 0.125rem;
}

.autocomplete-item-category {
    font-size: 0.8rem;
    color: #666;
}

/* Autocomplete States */
.autocomplete-loading,
.autocomplete-empty,
.autocomplete-error {
    padding: 1rem;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

.autocomplete-error {
    color: #dc3545;
}

/* Selected Ingredient Display */
.selected-ingredient {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(40, 167, 69, 0.1);
    border: 1px solid rgba(40, 167, 69, 0.3);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-top: 0.75rem;
}

.selected-ingredient-name {
    font-weight: 500;
    color: #218838;
}

.btn-remove-selection {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: background-color 0.15s ease;
}

.btn-remove-selection:hover {
    background-color: rgba(220, 53, 69, 0.1);
}

/* Mobile adjustments for autocomplete */
@media (max-width: 575.98px) {
    .autocomplete-dropdown {
        max-height: 200px;
    }

    .autocomplete-item {
        padding: 0.625rem 0.875rem;
    }

    .autocomplete-item-name {
        font-size: 0.95rem;
    }

    .autocomplete-item-category {
        font-size: 0.75rem;
    }
}

/* =============================================================================
   ADD MEAL BUTTON AND MENU
   ============================================================================= */

/* Add Meal Button Container */
.diary-add-meal-container {
    padding: 1rem;
    display: flex;
    justify-content: center;
}

/* Add Meal Button */
.btn-add-meal {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #8B0000 0%, #DC143C 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(139, 0, 0, 0.3);
}

.btn-add-meal:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(139, 0, 0, 0.4);
}

.btn-add-meal:active {
    transform: translateY(0);
}

/* Meal Type Selection Modal */
.meal-type-menu {
    max-width: 340px;
}

.meal-type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.meal-type-option {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.5rem;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.meal-type-option:hover:not(.disabled) {
    background: #fff;
    border-color: #8B0000;
    box-shadow: 0 2px 8px rgba(139, 0, 0, 0.15);
}

.meal-type-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e9ecef;
}

.meal-type-option i:first-child {
    font-size: 1.5rem;
    color: #8B0000;
}

.meal-type-option.disabled i:first-child {
    color: #6c757d;
}

.meal-type-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #333;
    text-align: center;
}

.meal-type-check {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    font-size: 0.9rem;
    color: #198754;
}

/* Selected meal type option */
.meal-type-option.selected {
    background: #fff;
    border-color: #8B0000;
    box-shadow: 0 2px 8px rgba(139, 0, 0, 0.2);
}

.meal-type-option.selected i:first-child {
    color: #DC143C;
}

/* Time input styling for meal type menu */
.meal-type-menu .form-group .form-label {
    font-weight: 500;
    color: #555;
    margin-bottom: 0.5rem;
    display: block;
}

.meal-type-menu input[type="time"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}

.meal-type-menu input[type="time"]:focus {
    border-color: #8B0000;
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1);
    outline: none;
}

/* Empty state styling */
.diary-empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #6c757d;
}

.diary-empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.diary-empty-state p {
    margin: 0;
}

@media (max-width: 575.98px) {
    .meal-type-menu {
        max-width: none;
    }
}

/* ==========================================
   USER PROFILE OVERLAY
   ========================================== */

/* Profile button in navbar */
.btn-profile {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: 2px solid var(--primary-color, #8B0000);
    color: var(--primary-color, #8B0000) !important;
    border-radius: 25px;
    padding: 0.4rem 0.9rem;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn-profile:hover {
    background: var(--primary-color, #8B0000);
    color: white !important;
    box-shadow: 0 3px 8px rgba(139, 0, 0, 0.3);
}

.btn-profile i {
    font-size: 1.1rem;
}

@media (max-width: 575.98px) {
    .btn-profile {
        padding: 0.6rem;
        border-radius: 50%;
        width: 42px;
        height: 42px;
        justify-content: center;
    }
}

/* Profile overlay */
.profile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-50, #f9fafb);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    animation: slideInFromRight 0.3s var(--ease-out, ease-out);
}

.profile-overlay.closing {
    animation: slideOutToRight 0.3s ease-in forwards;
}

/* Profile header */
.profile-header {
    background-color: white;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-xs, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
    padding-top: max(0.875rem, env(safe-area-inset-top));
}

.profile-header .profile-title {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: #333;
}

/* Profile content */
.profile-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    padding-bottom: 90px;
    -webkit-overflow-scrolling: touch;
}

/* Profile loading */
.profile-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

/* Profile footer */
.profile-footer {
    background: white;
    border-top: 1px solid var(--gray-200, #e5e7eb);
    padding: 0.75rem 1rem;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    flex-shrink: 0;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
}

.profile-footer .btn {
    min-width: 130px;
    font-weight: 600;
    border-radius: 8px;
}

.profile-footer .btn-primary {
    background: linear-gradient(135deg, var(--primary-color, #8B0000) 0%, var(--secondary-color, #DC143C) 100%);
    border: none;
}

.profile-footer .btn-primary:hover {
    box-shadow: 0 3px 8px rgba(139, 0, 0, 0.3);
}

.profile-footer .btn-primary:disabled {
    opacity: 0.6;
}

/* Profile cards */
.profile-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.profile-card {
    background: white;
    border-radius: var(--radius-xl, 12px);
    padding: 1rem;
    border: 1px solid var(--gray-200, #e5e7eb);
    transition: border-color var(--duration-fast, 0.2s);
}

.profile-card:focus-within {
    border-color: var(--primary-color, #8B0000);
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.08);
}

.profile-card-readonly {
    background: #f8f9fa;
}

.profile-card-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.profile-card-value {
    font-size: 1.1rem;
    font-weight: 500;
    color: #333;
}

.profile-card-unit {
    font-size: 0.85rem;
    color: #6c757d;
    margin-left: 0.25rem;
}

/* Profile form inputs */
.profile-card .form-control,
.profile-card .form-select {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
}

.profile-card .form-control:focus,
.profile-card .form-select:focus {
    border-color: var(--primary-color, #8B0000);
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1);
}

/* Tag styles */
.profile-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.profile-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--primary-color, #8B0000);
    color: white;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.profile-tag .tag-remove {
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.15rem;
    opacity: 0.7;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.profile-tag .tag-remove:hover {
    opacity: 1;
}

.profile-tag-input {
    border: 1px dashed #ccc;
    border-radius: 20px;
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
    outline: none;
    min-width: 120px;
    background: transparent;
}

.profile-tag-input:focus {
    border-color: var(--primary-color, #8B0000);
    border-style: solid;
}

.profile-tag-input::placeholder {
    color: #adb5bd;
}

/* Profile section divider */
.profile-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary-color, #8B0000);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 1.25rem 0 0.5rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid var(--primary-color, #8B0000);
    display: inline-block;
}

/* Read-only section */
.profile-readonly-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.profile-readonly-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

/* Toast notification */
.profile-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 1060;
    animation: fadeInUp 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.profile-toast.success {
    background: #198754;
}

.profile-toast.error {
    background: #dc3545;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Responsive */
@media (max-width: 576px) {
    .profile-content {
        padding: 0.75rem;
        padding-bottom: 90px;
    }

    .profile-card {
        padding: 0.75rem;
    }

    .profile-footer .btn {
        min-width: 110px;
        font-size: 0.9rem;
    }

    .profile-readonly-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================
   WEIGHT CALENDAR
   ========================================== */

/* Button below weight field in profile */
.btn-weight-calendar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    border: 1px dashed var(--primary-color, #8B0000);
    color: var(--primary-color, #8B0000);
    background: transparent;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem;
    margin-top: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-weight-calendar:hover {
    background: rgba(139, 0, 0, 0.08);
    border-color: var(--primary-color, #8B0000);
}

.btn-weight-calendar:active {
    transform: scale(0.98);
}

/* Smoking habits */
.smoking-habits-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.smoking-type-row {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 0.75rem;
}

.smoking-type-row .form-check {
    margin-bottom: 0;
}

.smoking-type-row .form-check-label {
    font-size: 0.9rem;
    font-weight: 500;
}

.smoking-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-left: 1.5rem;
    align-items: center;
}

.smoking-detail .smoking-qty {
    width: 80px;
    flex-shrink: 0;
}

.smoking-detail .smoking-unit {
    flex: 1;
    min-width: 140px;
}

.smoking-detail .smoking-custom-desc {
    width: 100%;
}

/* Weight calendar overlay (full-screen, same pattern as profile overlay) */
.weight-calendar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-50, #f9fafb);
    z-index: 1055;
    display: flex;
    flex-direction: column;
    animation: slideInFromRight 0.3s var(--ease-out, ease-out);
}

.weight-calendar-overlay.closing {
    animation: slideOutToRight 0.3s ease-in forwards;
}

/* Header */
.weight-calendar-header {
    background-color: white;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-xs, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
    padding-top: max(0.875rem, env(safe-area-inset-top));
}

.weight-calendar-title {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: #333;
}

/* Body */
.weight-calendar-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    -webkit-overflow-scrolling: touch;
}

/* Calendar container */
.wc-calendar {
    max-width: 400px;
    margin: 0 auto;
    padding: 1rem;
}

/* Calendar header with month navigation (reuses diary-calendar-* classes from food-diary) */
.wc-calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding: 0 0.5rem;
}

/* Calendar legend */
.wc-calendar-legend {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 8px;
}

/* Green indicator for dates with weight entries */
.diary-calendar-indicator.wc-has-weight {
    background: #28a745;
    border: 1px solid #218838;
}

/* Loading spinner */
.wc-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-light, #666);
    gap: 0.5rem;
    font-size: 0.9rem;
}

.wc-loading .spinner-border {
    width: 1.25rem;
    height: 1.25rem;
    border-width: 2px;
}

/* ---- Entries Panel (below calendar) ---- */

.wc-entries-panel {
    max-width: 400px;
    margin: 1rem auto 0;
    padding: 0 1rem;
}

.wc-entries-header {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color, #8B0000);
}

.wc-entries-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.wc-entries-empty {
    text-align: center;
    color: var(--text-light, #666);
    font-size: 0.9rem;
    padding: 1.5rem 0;
    font-style: italic;
}

/* Single entry row */
.wc-entry-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: white;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    transition: opacity 0.3s, transform 0.3s;
}

.wc-entry-item.deleting {
    opacity: 0.5;
    pointer-events: none;
}

.wc-entry-item.deleted {
    animation: slideOutRight 0.3s ease forwards;
}

/* Editable weight value (reuse diary-quantity pattern) */
.wc-entry-value {
    display: inline-flex;
    align-items: center;
    background-color: rgba(139, 0, 0, 0.1);
    color: var(--primary-color, #8B0000);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 70px;
    justify-content: center;
}

.wc-entry-value.editable {
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    user-select: none;
}

.wc-entry-value.editable:hover {
    background-color: rgba(139, 0, 0, 0.2);
    transform: scale(1.02);
}

.wc-entry-value.editable:active {
    transform: scale(0.98);
}

.wc-entry-value.saving {
    opacity: 0.6;
    pointer-events: none;
}

.wc-entry-value.saving::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 4px;
    border: 2px solid var(--primary-color, #8B0000);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.wc-entry-value.error {
    background-color: rgba(220, 53, 69, 0.15);
    border: 1px solid #dc3545;
    animation: shake 0.3s ease;
}

/* Edit inputs (weight inline) */
.wc-edit-input {
    border: 2px solid var(--primary-color, #8B0000);
    border-radius: 6px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.25rem 0.375rem;
    background-color: white;
    color: var(--primary-color, #8B0000);
    outline: none;
}

.wc-edit-input:focus {
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.15);
}

.wc-weight-input {
    width: 75px;
}

/* Hide number spinner */
.wc-weight-input::-webkit-outer-spin-button,
.wc-weight-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.wc-weight-input {
    -moz-appearance: textfield;
}

/* Delete weight button (reuse btn-delete-ingredient pattern) */
.btn-delete-weight {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: auto;
}

.btn-delete-weight:hover {
    background: rgba(220, 53, 69, 0.2);
}

.btn-delete-weight:active {
    transform: scale(0.95);
}

.btn-delete-weight i {
    font-size: 0.9rem;
    pointer-events: none;
}

/* ---- Add Row ---- */

.wc-add-container {
    margin-top: 0.75rem;
    display: flex;
    justify-content: center;
}

.btn-wc-add {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
}

.btn-wc-add:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.4);
}

.btn-wc-add:active {
    transform: translateY(0);
}

.btn-wc-add i {
    font-size: 1rem;
}

/* Add new entry inline row */
.wc-add-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: white;
    border-radius: 10px;
    border: 2px dashed var(--primary-color, #8B0000);
    margin-top: 0.5rem;
}

.wc-add-row .wc-edit-input {
    flex-shrink: 0;
}

.btn-wc-confirm {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(40, 167, 69, 0.15);
    color: #28a745;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-wc-confirm:hover {
    background: rgba(40, 167, 69, 0.25);
}

.btn-wc-confirm:active {
    transform: scale(0.95);
}

.btn-wc-cancel {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(108, 117, 125, 0.1);
    color: #6c757d;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-wc-cancel:hover {
    background: rgba(108, 117, 125, 0.2);
}

.btn-wc-cancel:active {
    transform: scale(0.95);
}

.btn-wc-confirm i,
.btn-wc-cancel i {
    font-size: 0.9rem;
    pointer-events: none;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .weight-calendar-body {
        padding: 0.75rem;
    }

    .wc-calendar {
        padding: 0.5rem;
    }

    .wc-entries-panel {
        padding: 0 0.5rem;
    }

    .wc-entry-item {
        gap: 0.5rem;
        padding: 0.6rem;
    }

    .btn-delete-weight {
        width: 40px;
        height: 40px;
    }

    .wc-add-row {
        gap: 0.375rem;
    }

    .btn-wc-confirm,
    .btn-wc-cancel {
        width: 40px;
        height: 40px;
    }
}

/* ==================== NUTRIENT DASHBOARD ==================== */

/* Dashboard Button - Filled style matching Diary button */
.btn-dashboard {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color, #8B0000) 0%, var(--secondary-color, #DC143C) 100%);
    color: white !important;
    border: none;
    border-radius: 25px;
    padding: 0.5rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 3px 8px rgba(139, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.btn-dashboard:hover {
    background: linear-gradient(135deg, var(--secondary-color, #DC143C) 0%, var(--primary-color, #8B0000) 100%);
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(139, 0, 0, 0.4);
}

.btn-dashboard:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(139, 0, 0, 0.3);
}

.btn-dashboard i {
    font-size: 1.1rem;
}

@media (max-width: 575.98px) {
    .btn-dashboard {
        padding: 0.6rem;
        border-radius: 50%;
        width: 42px;
        height: 42px;
        justify-content: center;
    }

    .btn-dashboard i {
        font-size: 1.2rem;
    }
}

/* Dashboard overlay */
.dashboard-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-50, #f9fafb);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    animation: slideInFromRight 0.3s var(--ease-out, ease-out);
}

.dashboard-overlay.closing {
    animation: slideOutToRight 0.3s ease-in forwards;
}

/* Dashboard header */
.dashboard-header {
    background-color: white;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: var(--shadow-xs, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
    padding-top: max(0.875rem, env(safe-area-inset-top));
}

.dashboard-header .dashboard-title {
    margin: 0;
    font-weight: 700;
    color: #333;
    font-size: 1.1rem;
}

.dashboard-header .close-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: #666;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    transition: all 0.2s;
}

.dashboard-header .close-btn:hover {
    color: var(--primary-color, #8B0000);
    background-color: rgba(139, 0, 0, 0.1);
}

/* Dashboard content area */
.dashboard-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    -webkit-overflow-scrolling: touch;
}

/* Loading state */
.dashboard-loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Time range selector — pill buttons */
.dashboard-time-range {
    display: flex;
    justify-content: center;
    gap: 0.375rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    background: var(--gray-100, #f3f4f6);
    border-radius: var(--radius-full, 9999px);
    padding: 0.25rem;
}

.dashboard-time-range .time-btn {
    padding: 0.35rem 0.875rem;
    border: none;
    background: transparent;
    color: var(--gray-600, #4b5563);
    border-radius: var(--radius-full, 9999px);
    font-size: var(--text-xs, 0.75rem);
    font-weight: var(--font-semibold, 600);
    cursor: pointer;
    transition: all var(--duration-fast, 0.2s);
}

.dashboard-time-range .time-btn:hover {
    background: var(--gray-200, #e5e7eb);
    color: var(--gray-800, #1f2937);
}

.dashboard-time-range .time-btn.active {
    background: white;
    color: var(--primary-color, #8B0000);
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.1));
}

/* Chart wrapper */
.dashboard-chart-wrapper {
    background: white;
    border-radius: var(--radius-xl, 12px);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm, 0 2px 6px rgba(0, 0, 0, 0.08));
    border: 1px solid var(--gray-100, #f3f4f6);
}

.dashboard-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dashboard-chart-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
    margin: 0;
}

/* Nutrient dropdown */
.dashboard-nutrient-select {
    padding: 0.25rem 0.5rem;
    border: 1.5px solid #dee2e6;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #555;
    background: white;
    cursor: pointer;
    max-width: 180px;
    transition: border-color 0.2s;
}

.dashboard-nutrient-select:focus {
    outline: none;
    border-color: var(--primary-color, #8B0000);
    box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.1);
}

/* Canvas container for Chart.js */
.dashboard-chart-canvas-container {
    position: relative;
    height: 200px;
}

/* Empty state */
.dashboard-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #888;
}

.dashboard-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #ccc;
}

.dashboard-empty p {
    font-size: 1rem;
    margin: 0;
}

/* Responsive */
@media (min-width: 768px) {
    .dashboard-chart-canvas-container {
        height: 250px;
    }

    .dashboard-content {
        padding: 1.5rem 2rem;
        max-width: 900px;
        margin: 0 auto;
        width: 100%;
    }
}

/* ==========================================
   DOCTOR MODE - ROLE TOGGLE & PATIENT BAR
   ========================================== */

/* Role Toggle Button */
.btn-role-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.9rem;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    border: 2px solid var(--primary-color, #8B0000);
    background: transparent;
    color: var(--primary-color, #8B0000);
    cursor: pointer;
}

.btn-role-toggle:hover {
    background: var(--primary-color, #8B0000);
    color: white;
}

.btn-role-toggle i {
    font-size: 1rem;
}

/* Doctor mode active state */
body.doctor-mode .btn-role-toggle {
    background: var(--doctor-primary, #0056B3);
    border-color: var(--doctor-primary, #0056B3);
    color: white;
}

body.doctor-mode .btn-role-toggle:hover {
    background: var(--doctor-secondary, #007BFF);
    border-color: var(--doctor-secondary, #007BFF);
}

/* Mobile: icon only */
@media (max-width: 575.98px) {
    .btn-role-toggle {
        padding: 0.5rem;
        border-radius: 50%;
        width: 38px;
        height: 38px;
        justify-content: center;
    }
}

/* Patient Selection Bar (visible in doctor mode) */
.patient-selection-bar {
    background: white;
    border-bottom: 2px solid var(--doctor-secondary, #007BFF);
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    animation: slideDown 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 86, 179, 0.1);
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.patient-selection-bar .selected-patient-info {
    flex: 1;
    font-weight: 500;
    color: var(--doctor-primary, #0056B3);
    display: flex;
    align-items: center;
    font-size: 0.95rem;
}

.patient-selection-bar .selected-patient-info i {
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.patient-selection-bar .selected-patient-info strong {
    font-weight: 700;
}

.patient-selection-bar .btn-change-patient {
    background: var(--doctor-secondary, #007BFF);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.patient-selection-bar .btn-change-patient:hover {
    background: var(--doctor-primary, #0056B3);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 86, 179, 0.3);
}

.patient-selection-bar .patient-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.patient-selection-bar .btn-invite-patient {
    background: white;
    border: 2px solid var(--doctor-secondary, #007BFF);
    color: var(--doctor-secondary, #007BFF);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.patient-selection-bar .btn-invite-patient:hover {
    background: var(--doctor-secondary, #007BFF);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 86, 179, 0.3);
}

/* Mobile adjustments for patient bar */
@media (max-width: 575.98px) {
    .patient-selection-bar {
        padding: 0.5rem 0.75rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .patient-selection-bar .selected-patient-info {
        font-size: 0.85rem;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .patient-selection-bar .btn-change-patient {
        font-size: 0.8rem;
        padding: 0.35rem 0.75rem;
    }
}

/* Patient Search Modal */
.patient-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.patient-search-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 450px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.patient-search-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.patient-search-header h5 {
    margin: 0;
    font-weight: 600;
    color: var(--doctor-primary, #0056B3);
    font-size: 1.1rem;
}

.patient-search-header .btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.patient-search-header .btn-close:hover {
    color: #333;
}

.patient-search-body {
    padding: 1.25rem;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.patient-search-body .form-label {
    font-weight: 500;
    color: #555;
    margin-bottom: 0.5rem;
}

.patient-search-body .form-control {
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.patient-search-body .form-control:focus {
    border-color: var(--doctor-secondary, #007BFF);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

/* Patient autocomplete in doctor mode */
.patient-search-body .autocomplete-dropdown {
    border-radius: 10px;
    margin-top: 0.5rem;
    position: relative;
    top: 0;
    border: 1px solid #e9ecef;
}

.patient-search-body .autocomplete-item:hover,
.patient-search-body .autocomplete-item.active {
    background-color: rgba(0, 123, 255, 0.08);
}

.patient-search-body .autocomplete-item.active {
    background-color: rgba(0, 123, 255, 0.12);
}

/* Doctor mode theme adjustments for existing components */
body.doctor-mode .btn-diary,
body.doctor-mode .btn-dashboard {
    background: linear-gradient(135deg, var(--doctor-primary, #0056B3) 0%, var(--doctor-secondary, #007BFF) 100%);
    box-shadow: 0 3px 8px rgba(0, 86, 179, 0.3);
}

body.doctor-mode .btn-diary:hover,
body.doctor-mode .btn-dashboard:hover {
    background: linear-gradient(135deg, var(--doctor-secondary, #007BFF) 0%, var(--doctor-primary, #0056B3) 100%);
    box-shadow: 0 5px 15px rgba(0, 86, 179, 0.4);
}

body.doctor-mode .btn-profile {
    border-color: var(--doctor-primary, #0056B3);
    color: var(--doctor-primary, #0056B3) !important;
}

body.doctor-mode .btn-profile:hover {
    background: var(--doctor-primary, #0056B3);
    color: white !important;
    box-shadow: 0 3px 8px rgba(0, 86, 179, 0.3);
}

body.doctor-mode .navbar-brand {
    color: var(--doctor-primary, #0056B3) !important;
}

/* Doctor mode overlay headers */
body.doctor-mode .profile-header,
body.doctor-mode .diary-header,
body.doctor-mode .dashboard-header {
    border-bottom-color: var(--doctor-secondary, #007BFF);
}

body.doctor-mode .close-btn:hover,
body.doctor-mode .back-btn:hover,
body.doctor-mode .day-nav-btn:hover {
    color: var(--doctor-primary, #0056B3);
    background-color: rgba(0, 86, 179, 0.1);
}

body.doctor-mode .day-nav-btn {
    color: var(--doctor-primary, #0056B3);
}

body.doctor-mode .day-nav-btn:disabled {
    color: #ccc;
    background: none;
}

/* =========================================================================
   MEDICAL DATA EDITOR STYLES
   ========================================================================= */

.medical-data-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.medical-data-container {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.medical-data-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--doctor-primary, #0056B3), var(--doctor-secondary, #007BFF));
    color: white;
}

.medical-data-header h5 {
    margin: 0;
    font-weight: 600;
}

.medical-data-header .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.medical-data-header .close-btn:hover {
    opacity: 1;
}

/* Tabs */
.medical-data-tabs {
    display: flex;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.medical-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-light, #666);
    font-weight: 500;
    font-size: 0.9rem;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.medical-tab:hover {
    color: var(--doctor-primary, #0056B3);
    background: rgba(0, 86, 179, 0.05);
}

.medical-tab.active {
    color: var(--doctor-primary, #0056B3);
    border-bottom-color: var(--doctor-primary, #0056B3);
}

/* Content */
.medical-data-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

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

.content-header h6 {
    margin: 0;
    font-weight: 600;
    color: var(--text-dark, #333);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light, #666);
}

.empty-state i {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.empty-state small {
    opacity: 0.8;
}

/* Anamnesis sections */
.anamnesis-section {
    margin-bottom: 1.5rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
    margin-bottom: 0.75rem;
    font-weight: 500;
    color: var(--text-dark, #333);
}

/* Entry cards */
.entry-card,
.recommendation-card,
.note-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    position: relative;
    transition: all 0.2s;
}

.entry-card:hover,
.recommendation-card:hover,
.note-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.entry-card.own-entry,
.recommendation-card.own-entry,
.note-card.own-entry {
    border-left: 3px solid var(--doctor-primary, #0056B3);
}

.entry-card.other-entry,
.recommendation-card.other-entry,
.note-card.other-entry {
    border-left: 3px solid #aaa;
    background: #fafafa;
}

.entry-main {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.entry-title {
    font-weight: 500;
    color: var(--text-dark, #333);
}

.entry-value {
    color: var(--doctor-primary, #0056B3);
    font-weight: 600;
}

.entry-meta,
.rec-meta,
.note-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.entry-actions {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.15s;
}

.entry-card:hover .entry-actions,
.recommendation-card:hover .entry-actions,
.note-card:hover .entry-actions {
    opacity: 1;
}

.btn-action {
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    color: var(--text-light, #666);
    border-radius: 4px;
    transition: all 0.15s;
}

.btn-action:hover {
    background: #f0f0f0;
    color: var(--text-dark, #333);
}

.btn-action.delete-entry:hover {
    background: #fee;
    color: #dc3545;
}

/* Recommendations */
.recommendation-card.expired {
    opacity: 0.6;
}

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

.rec-type {
    font-size: 0.85rem;
    color: var(--text-light, #666);
}

.rec-priority {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
}

.rec-priority.priority-high {
    background: #fee;
    color: #dc3545;
}

.rec-priority.priority-medium {
    background: #fff3cd;
    color: #856404;
}

.rec-priority.priority-low {
    background: #d4edda;
    color: #155724;
}

.rec-content {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

/* Notes */
.note-content {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
    white-space: pre-wrap;
}

/* Loading */
.medical-data-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    z-index: 10;
}

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

.medical-modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.medical-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
}

.medical-modal-header h6 {
    margin: 0;
    font-weight: 600;
}

.medical-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.medical-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #eee;
}

/* Error state */
.error-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #dc3545;
}

.error-state i {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

/* Responsive */
@media (max-width: 576px) {
    .medical-data-container {
        max-height: 100vh;
        border-radius: 0;
    }

    .medical-tab {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .medical-tab i {
        display: block;
        margin-bottom: 0.25rem;
    }

    .entry-actions {
        opacity: 1;
    }
}

/* =========================================================================
   INVITATION FORM STYLES
   ========================================================================= */

.invitation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.invitation-container {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.invitation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--doctor-primary, #0056B3), var(--doctor-secondary, #007BFF));
    color: white;
}

.invitation-header h5 {
    margin: 0;
    font-weight: 600;
}

.invitation-header .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.8;
}

.invitation-header .close-btn:hover {
    opacity: 1;
}

.invitation-form-section {
    padding: 1.5rem;
    border-bottom: 1px solid #eee;
}

.invitation-form-section h6 {
    margin: 0 0 1rem;
    font-weight: 600;
    color: var(--text-dark, #333);
}

.invitation-list-section {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.invitation-list-section h6 {
    margin: 0 0 1rem;
    font-weight: 600;
    color: var(--text-dark, #333);
}

.invitation-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.invitation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

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

.invitation-email {
    font-weight: 500;
    color: var(--text-dark, #333);
    margin-bottom: 0.25rem;
}

.invitation-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.invitation-status {
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
}

.invitation-status.status-pending {
    background: #fff3cd;
    color: #856404;
}

.invitation-status.status-accepted {
    background: #d4edda;
    color: #155724;
}

.invitation-status.status-expired,
.invitation-status.status-cancelled {
    background: #f8d7da;
    color: #721c24;
}

/* Patient registration status badges */
.patient-status {
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.patient-status.patient-status-registered {
    background: #e7f3ff;
    color: #0066cc;
}

.patient-status.patient-status-profiled {
    background: #d4edda;
    color: #155724;
}

.invitation-date,
.invitation-expires {
    color: var(--text-light, #666);
}

.invitation-actions {
    display: flex;
    gap: 0.25rem;
}

.invitation-empty,
.invitation-error {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-light, #666);
}

.invitation-empty i,
.invitation-error i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.invitation-error {
    color: #dc3545;
}

.invitation-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    z-index: 10;
}

/* Accept Invitation Modal */
.accept-invitation-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.accept-modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.accept-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #eee;
    background: linear-gradient(135deg, var(--primary-color, #8B0000), var(--secondary-color, #DC143C));
    color: white;
    border-radius: 12px 12px 0 0;
}

.accept-modal-header h5 {
    margin: 0;
    font-weight: 600;
}

.accept-modal-body {
    padding: 1.5rem;
}

.accept-info {
    color: var(--text-dark, #333);
}

.accept-info p {
    margin-bottom: 1rem;
}

.doctor-info {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.doctor-info .info-item {
    margin-bottom: 0.5rem;
}

.doctor-info .info-item:last-child {
    margin-bottom: 0;
}

.accept-info ul {
    margin: 0;
    padding-left: 1.5rem;
}

.accept-info li {
    margin-bottom: 0.5rem;
}

.accept-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #eee;
}

/* Responsive */
@media (max-width: 576px) {
    .invitation-container,
    .accept-modal-content {
        max-height: 100vh;
        border-radius: 0;
    }

    .invitation-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .invitation-actions {
        align-self: flex-end;
    }
}

/* ==================== WATER TRACKER ==================== */

/* Water Popover */
.water-popover {
    position: fixed;
    z-index: 1100;
    width: 220px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.water-popover--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.water-popover-header {
    background: linear-gradient(135deg, #4FC3F7 0%, #0288D1 100%);
    color: white;
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.water-popover-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

/* Progress ring */
.water-ring-container {
    position: relative;
    width: 100px;
    height: 100px;
}

.water-ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.water-ring-count {
    font-size: 1.8rem;
    font-weight: 700;
    color: #0288D1;
    line-height: 1;
}

.water-label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

.water-liters {
    font-size: 0.8rem;
    color: #999;
    margin-bottom: 0.5rem;
}

/* +/- controls */
.water-controls {
    display: flex;
    gap: 1rem;
    margin: 0.25rem 0;
}

.water-btn-minus,
.water-btn-plus {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #4FC3F7;
    background: white;
    color: #0288D1;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.water-btn-plus {
    background: #4FC3F7;
    color: white;
    border-color: #4FC3F7;
}

.water-btn-minus:hover:not(:disabled) {
    background: #E1F5FE;
}

.water-btn-plus:hover {
    background: #0288D1;
    border-color: #0288D1;
}

.water-btn-minus:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.water-btn-minus:active:not(:disabled),
.water-btn-plus:active {
    transform: scale(0.9);
}

.water-goal {
    font-size: 0.75rem;
    color: #aaa;
    margin-top: 0.25rem;
}

/* Water section in daily summary – styled like other nutrient rows */
.summary-expand-section {
    text-align: center;
    padding: 4px 0 0;
    border-top: 1px solid #f0f0f0;
    margin-top: 8px;
}

/* Override circle style for the daily summary expand button (has text label) */
.summary-expand-section .btn-expand-nutrients {
    width: auto;
    height: auto;
    min-width: unset;
    min-height: 36px;
    border-radius: 18px;
    padding: 0.25rem 0.75rem;
    margin: 0 auto;
    font-size: 0.8rem;
}

.summary-water-section {
    margin-top: 0;
}

.summary-water-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.06);
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-dark, #333);
}

.summary-water-header i {
    color: #0288D1;
    margin-right: 0.35rem;
}

.summary-water-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0;
    font-size: 0.85rem;
    padding-left: 1.25rem;
    margin-left: 0.5rem;
    border-left: 2px solid rgba(139, 0, 0, 0.15);
}

.summary-water-row.totale {
    font-weight: 600;
    border-left-color: rgba(139, 0, 0, 0.25);
}

.summary-water-row .water-sub-label {
    font-weight: 400;
    color: var(--text-light, #666);
}

.summary-water-row .water-sub-value {
    font-weight: 500;
    color: var(--text-dark, #555);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Inline +/- buttons for water in summary */
.water-inline-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1.5px solid #4FC3F7;
    background: white;
    color: #0288D1;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
}

.water-inline-btn:hover:not(:disabled) {
    background: #E1F5FE;
}

.water-inline-btn.plus {
    background: #4FC3F7;
    color: white;
}

.water-inline-btn.plus:hover {
    background: #0288D1;
    border-color: #0288D1;
}

.water-inline-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.water-inline-btn:active:not(:disabled) {
    transform: scale(0.9);
}

/* Custom water input in popover */
.water-custom-row {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding: 0 0.25rem;
}

.water-custom-input {
    width: 70px;
    padding: 0.3rem 0.4rem;
    border: 1.5px solid #B3E5FC;
    border-radius: 6px;
    font-size: 0.8rem;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

.water-custom-input:focus {
    border-color: #4FC3F7;
}

.water-custom-input::placeholder {
    color: #B3E5FC;
}

.water-custom-btn {
    flex: 1;
    padding: 0.3rem 0.5rem;
    background: #4FC3F7;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.water-custom-btn:hover {
    background: #0288D1;
}

/* ============================================================================
   PROFILE BODY PHOTO (patient self-service)
   ============================================================================ */

.profile-body-photo-area {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.profile-bp-placeholder,
.profile-bp-display,
.profile-bp-uploading {
    width: 160px;
    height: 200px;
    border-radius: 12px;
}

.profile-bp-placeholder {
    border: 2px dashed #d0d0d0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    gap: 8px;
    padding: 12px;
    text-align: center;
}

.profile-bp-placeholder i {
    font-size: 2rem;
    opacity: 0.5;
}

.profile-bp-instructions {
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.3;
    color: #6c757d;
}

.profile-bp-upload-btn {
    font-size: 0.75rem;
    padding: 3px 10px;
    margin-top: 4px;
}

.profile-bp-display {
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.profile-bp-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-bp-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    display: flex;
    gap: 6px;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.profile-bp-display:hover .profile-bp-overlay {
    opacity: 1;
}

/* On touch devices, always show overlay */
@media (hover: none) {
    .profile-bp-overlay {
        opacity: 1;
    }
}

.profile-bp-overlay .btn {
    font-size: 0.75rem;
    padding: 2px 8px;
}

.profile-bp-uploading {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
}

@media (max-width: 768px) {
    .profile-bp-placeholder,
    .profile-bp-display,
    .profile-bp-uploading {
        width: 120px;
        height: 150px;
    }
}

/* ============================================
   Daily Summary Strip
   ============================================ */

.daily-summary-strip {
    flex-shrink: 0;
    background: white;
    border-bottom: 1px solid #dee2e6;
    padding: 0;
}

/* Loading state */
.ds-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* Main content */
.ds-content {
    padding: 0.75rem 1rem;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    max-height: 500px;
    overflow: hidden;
}

.ds-content.ds-collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0 1rem;
    pointer-events: none;
}

/* Doctor placeholder */
.ds-content.ds-doctor-placeholder {
    text-align: center;
    color: var(--text-light, #666);
}

.ds-content.ds-doctor-placeholder .ds-greeting {
    justify-content: center;
}

/* Greeting */
.ds-greeting {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dark, #333);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Energy bar area */
.ds-energy-area {
    cursor: pointer;
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
    border-radius: 8px;
    transition: background-color 0.15s;
}

.ds-energy-area:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.ds-energy-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ds-energy-bar-track {
    flex: 1;
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
}

.ds-energy-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.6s ease-out;
    width: 0%;
}

/* Bar color variants */
.ds-bar--under {
    background: linear-gradient(90deg, #4a90d9, #5ba3ec);
}
.ds-bar--good {
    background: linear-gradient(90deg, #28a745, #34c759);
}
.ds-bar--over {
    background: linear-gradient(90deg, #f0ad4e, #e89b20);
}
.ds-bar--excess {
    background: linear-gradient(90deg, #dc3545, #c82333);
}

.ds-energy-pct {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dark, #333);
    min-width: 2.5rem;
    text-align: right;
}

.ds-energy-label {
    font-size: 0.75rem;
    color: var(--text-light, #666);
    margin-top: 0.125rem;
}

.ds-energy-tee-ref {
    display: block;
    font-size: 0.65rem;
    color: #999;
    margin-top: 0.05rem;
}

/* Macros row */
.ds-macros-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    cursor: pointer;
    padding: 0.125rem 0;
}

.ds-macros-row::-webkit-scrollbar {
    display: none;
}

.ds-macro-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    animation: dsPillFadeIn 0.3s ease both;
}

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

.ds-macro-protein {
    background: rgba(220, 53, 69, 0.1);
    color: #c92a2a;
}
.ds-macro-carbs {
    background: rgba(253, 126, 20, 0.1);
    color: #e67700;
}
.ds-macro-fat {
    background: rgba(32, 107, 196, 0.1);
    color: #1971c2;
}
.ds-macro-fiber {
    background: rgba(40, 167, 69, 0.1);
    color: #2b8a3e;
}

/* Eco pill in daily summary strip */
.ds-eco-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    animation: dsPillFadeIn 0.3s ease both;
    cursor: pointer;
    gap: 0.25rem;
    margin-left: 0.25rem;
}

/* Eco-score colors (A-E) */
.env-score-A { background: #2d8a4e; color: white; }
.env-score-B { background: #85bb2f; color: white; }
.env-score-C { background: #fecb02; color: #333; }
.env-score-D { background: #ee8100; color: white; }
.env-score-E { background: #e63e11; color: white; }

/* Softer background for eco pill in daily summary strip */
.ds-eco-pill.env-score-A { background: rgba(45, 138, 78, 0.35); color: #1a5e32; }
.ds-eco-pill.env-score-B { background: rgba(133, 187, 47, 0.35); color: #4a6e10; }
.ds-eco-pill.env-score-C { background: rgba(254, 203, 2, 0.35); color: #7a6200; }
.ds-eco-pill.env-score-D { background: rgba(238, 129, 0, 0.35); color: #8a4a00; }
.ds-eco-pill.env-score-E { background: rgba(230, 62, 17, 0.35); color: #8a1a00; }

/* Environmental row in food diary meal list */
.fd-env-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-light, #666);
}

.fd-eco-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.fd-dish-eco-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-left: 0.4rem;
    vertical-align: middle;
}

.fd-env-row span {
    white-space: nowrap;
}

/* Environmental section in daily summary (matches water section style) */
.summary-env-section {
    margin-top: 0;
}

.summary-env-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0;
    font-size: 0.85rem;
    padding-left: 1.25rem;
    margin-left: 0.5rem;
    border-left: 2px solid rgba(45, 138, 78, 0.2);
}

/* Bottom row: water + weight */
.ds-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Water row */
.ds-water-row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.85rem;
    color: var(--text-dark, #333);
}

.ds-water-count {
    font-weight: 700;
    transition: transform 0.2s ease;
}

.ds-water-label {
    color: var(--text-light, #666);
    font-size: 0.8rem;
}

/* Water status colors (consistent with energy bar colors) */
.ds-water--ok {
    color: #2b8a3e;
}
.ds-water--mid {
    color: #e67700;
}
.ds-water--low {
    color: #c92a2a;
}
.ds-water-status-icon {
    font-size: 0.75rem;
    margin-left: 0.25rem;
}
.ds-water--ok-icon {
    color: #28a745;
}
.ds-water--warn-icon {
    color: #e89b20;
}

/* Weight row */
.ds-weight-row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: background-color 0.15s;
}

.ds-weight-row:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.ds-weight-icon {
    color: var(--text-light, #666);
    font-size: 1rem;
}

.ds-weight-value {
    font-weight: 600;
    color: var(--text-dark, #333);
}

.ds-weight-date {
    color: var(--text-light, #999);
    font-size: 0.75rem;
}

/* Collapse handle */
.ds-collapse-handle {
    display: flex;
    justify-content: center;
    padding: 0.25rem 0 0;
    cursor: pointer;
    min-height: 20px;
}

.ds-collapse-bar {
    width: 32px;
    height: 3px;
    background: #ccc;
    border-radius: 2px;
    transition: background 0.15s;
}

.ds-collapse-handle:hover .ds-collapse-bar {
    background: #999;
}

/* Micro bar (collapsed state) */
.ds-micro-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.375rem 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-dark, #333);
    background: white;
    border-bottom: 1px solid #dee2e6;
    cursor: pointer;
    min-height: 32px;
}

.ds-micro-sep {
    color: #ccc;
}

/* ============================================
   Hamburger Menu Overlay (Mobile)
   ============================================ */

.btn-hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-dark, #333);
    font-size: 1.5rem;
    padding: 0.25rem;
    min-width: 44px;
    min-height: 44px;
}

.btn-hamburger:hover {
    color: var(--primary-color, #8B0000);
}

.nav-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1060;
}

.nav-menu-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.2s ease;
}

.nav-menu-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw;
    background: white;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    animation: slideInFromRight 0.25s var(--ease-out, ease-out);
}

.nav-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dee2e6;
    padding-top: max(1rem, env(safe-area-inset-top));
}

.nav-menu-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark, #333);
}

.nav-menu-close {
    background: none;
    border: none;
    color: var(--text-light, #666);
    font-size: 1.25rem;
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.15s;
}

.nav-menu-close:hover {
    background-color: #f5f5f5;
}

.nav-menu-items {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0;
    flex: 1;
}

.nav-menu-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.25rem;
    border: none;
    background: none;
    color: var(--text-dark, #333);
    font-size: 1rem;
    font-weight: var(--font-medium, 500);
    cursor: pointer;
    transition: background-color var(--duration-fast, 0.15s);
    text-align: left;
    min-height: 52px;
    /* Staggered entrance animation */
    opacity: 0;
    transform: translateX(20px);
    animation: navItemSlideIn 0.25s var(--ease-out, ease-out) forwards;
}

.nav-menu-item:nth-child(1) { animation-delay: 0.05s; }
.nav-menu-item:nth-child(2) { animation-delay: 0.1s; }
.nav-menu-item:nth-child(3) { animation-delay: 0.15s; }
.nav-menu-item:nth-child(4) { animation-delay: 0.2s; }
.nav-menu-item:nth-child(5) { animation-delay: 0.25s; }
.nav-menu-item:nth-child(6) { animation-delay: 0.3s; }
.nav-menu-item:nth-child(7) { animation-delay: 0.35s; }
.nav-menu-item:nth-child(8) { animation-delay: 0.4s; }

@keyframes navItemSlideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.nav-menu-item:hover {
    background-color: var(--red-50, #fef2f2);
}

.nav-menu-item:active {
    background-color: var(--red-100, #fee2e2);
}

.nav-menu-item i {
    font-size: 1.1rem;
    color: var(--primary-color, #8B0000);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--red-50, #fef2f2);
    border-radius: var(--radius-lg, 10px);
    flex-shrink: 0;
}

/* Closing animation */
.nav-menu-overlay.closing .nav-menu-backdrop {
    animation: fadeOut 0.2s ease forwards;
}

.nav-menu-overlay.closing .nav-menu-panel {
    animation: slideOutToRight 0.25s ease-in forwards;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ============================================
   Desktop: Two-Column Layout (sidebar + chat)
   ============================================ */

@media (min-width: 992px) {
    .chat-container {
        display: grid;
        grid-template-columns: 280px 1fr;
        grid-template-rows: 1fr auto;
        height: calc(100vh - 60px);
    }

    /* Sidebar = daily summary strip */
    .daily-summary-strip {
        grid-column: 1;
        grid-row: 1 / -1;
        border-bottom: none;
        border-right: 1px solid #dee2e6;
        overflow-y: auto;
        padding: 0;
    }

    .daily-summary-strip .ds-content {
        padding: 1.25rem 1rem;
    }

    /* Hide collapse handle on desktop */
    .daily-summary-strip .ds-collapse-handle,
    .daily-summary-strip .ds-micro-bar {
        display: none;
    }

    /* Desktop: stack items vertically with more spacing */
    .daily-summary-strip .ds-greeting {
        font-size: 1.05rem;
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
        border-bottom: 1px solid #eee;
    }

    .daily-summary-strip .ds-energy-area {
        margin-bottom: 1rem;
    }

    .daily-summary-strip .ds-macros-row {
        flex-wrap: wrap;
        margin-bottom: 1rem;
    }

    .daily-summary-strip .ds-bottom-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .daily-summary-strip .ds-water-row {
        padding: 0.625rem;
        background: rgba(79, 195, 247, 0.05);
        border-radius: 10px;
    }

    .daily-summary-strip .ds-weight-row {
        padding: 0.625rem;
        background: rgba(0, 0, 0, 0.02);
        border-radius: 10px;
    }

    /* Chat area spans right column */
    .chat-messages {
        grid-column: 2;
        grid-row: 1;
    }

    .chat-input-container {
        grid-column: 2;
        grid-row: 2;
    }
}

/* ============================================================================
 * ACTIVITY OVERLAY
 * ============================================================================ */

.activity-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-50, #f9fafb);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    animation: slideInFromRight 0.3s var(--ease-out, ease-out);
    overflow-y: auto;
}

.activity-overlay.closing {
    animation: slideOutToRight 0.3s ease-in forwards;
}

.activity-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

/* Activity header (day navigation) */
.act-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #fff;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    box-shadow: var(--shadow-xs, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
    position: sticky;
    top: 0;
    z-index: 10;
}

.act-nav-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #495057;
    padding: 0.25rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
}
.act-nav-btn:hover:not(:disabled) {
    background: rgba(0,0,0,0.05);
}
.act-nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.act-date-display {
    flex: 1;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.act-date-text {
    font-weight: 600;
    font-size: 1rem;
}

.act-today-btn {
    font-size: 0.75rem;
    background: #e9ecef;
    border: none;
    border-radius: 12px;
    padding: 0.15rem 0.5rem;
    color: #495057;
    cursor: pointer;
}
.act-today-btn:hover {
    background: #dee2e6;
}

.act-close-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #495057;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
}
.act-close-btn:hover {
    background: rgba(0,0,0,0.05);
}

/* Summary bar */
.act-summary-bar {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border-bottom: 1px solid #ffe0b2;
}

.act-summary-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.9rem;
}

.act-summary-icon {
    color: #e65100;
    font-size: 1rem;
}

.act-summary-value {
    font-weight: 700;
    color: #333;
}

.act-summary-label {
    color: #777;
    font-size: 0.8rem;
}

/* Add section */
.act-add-section {
    padding: 1rem;
    background: #fff;
    border-bottom: 1px solid #dee2e6;
}

.act-add-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.75rem;
}
.act-add-title i {
    color: #e65100;
}

/* Category pills */
.act-category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}

.act-category-pill {
    background: #f1f3f5;
    border: 1px solid #dee2e6;
    border-radius: 16px;
    padding: 0.2rem 0.625rem;
    font-size: 0.75rem;
    color: #495057;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.act-category-pill:hover {
    background: #ffe0b2;
    border-color: #e65100;
    color: #e65100;
}
.act-category-pill.active {
    background: #e65100;
    color: #fff;
    border-color: #e65100;
}

/* Activity type list (items within a category) */
.act-type-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #fafafa;
}

.act-type-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid #f0f0f0;
}
.act-type-item:last-child {
    border-bottom: none;
}
.act-type-item:hover {
    background: #fff3e0;
}
.act-type-item.selected {
    background: #fff3e0;
    border-left: 3px solid #e65100;
}

.act-type-item-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #333;
}

.act-type-item-met {
    font-size: 0.75rem;
    color: #999;
    white-space: nowrap;
    margin-left: 0.5rem;
}

/* Section divider (oppure) */
.act-section-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    color: #adb5bd;
    font-size: 0.75rem;
}
.act-section-divider::before,
.act-section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #dee2e6;
}

/* Search input */
.act-search-container {
    position: relative;
    margin-bottom: 0.75rem;
}

.act-search-input-wrap {
    position: relative;
}

.act-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
    font-size: 0.85rem;
    pointer-events: none;
}

.act-search-input {
    width: 100%;
    border: 1px solid #ced4da;
    border-radius: 8px;
    padding: 0.375rem 0.75rem 0.375rem 2rem;
    font-size: 0.875rem;
    background: #fff;
}
.act-search-input:focus {
    outline: none;
    border-color: #e65100;
    box-shadow: 0 0 0 2px rgba(230, 81, 0, 0.15);
}

.act-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1070;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-top: 4px;
    max-height: 320px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.act-search-item {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid #f8f9fa;
}
.act-search-item:last-child {
    border-bottom: none;
}
.act-search-item:hover,
.act-search-item.highlighted {
    background: #fff3e0;
}

.act-search-item-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #333;
}

.act-search-item-meta {
    font-size: 0.75rem;
    color: #999;
}

.act-search-cat-header {
    padding: 0.3rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #e65100;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
    position: sticky;
    top: 0;
    z-index: 1;
}

.act-search-empty {
    padding: 0.75rem;
    text-align: center;
    font-size: 0.85rem;
    color: #999;
}

/* Selected activity badge */
.act-selected-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: #fff3e0;
    border: 1px solid #e65100;
    border-radius: 20px;
    padding: 0.25rem 0.5rem 0.25rem 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.act-selected-name {
    font-weight: 600;
    color: #e65100;
}

.act-selected-met {
    font-size: 0.75rem;
    color: #bf360c;
    opacity: 0.8;
}

.act-selected-remove {
    background: none;
    border: none;
    color: #e65100;
    cursor: pointer;
    padding: 0.125rem;
    font-size: 1rem;
    line-height: 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.act-selected-remove:hover {
    background: rgba(230, 81, 0, 0.15);
}

/* Form row */
.act-form-row {
    margin-bottom: 0.75rem;
}

.act-form-inline {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.act-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.act-form-group label {
    font-size: 0.75rem;
    color: #777;
}

.act-form-notes {
    flex: 1;
}

.act-duration-input,
.act-notes-input {
    border: 1px solid #ced4da;
    border-radius: 8px;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    background: #fff;
    width: 100%;
}
.act-duration-input:focus,
.act-notes-input:focus {
    outline: none;
    border-color: #e65100;
    box-shadow: 0 0 0 2px rgba(230, 81, 0, 0.15);
}

.act-duration-input {
    width: 80px;
}

.act-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1.25rem;
    background: #e65100;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.act-add-btn:hover:not(:disabled) {
    background: #bf360c;
}
.act-add-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Activity list */
.act-list {
    padding: 0.75rem 1rem;
}

.act-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: #999;
}
.act-empty i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
    color: #ccc;
}

/* Activity card */
.act-card {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #fff;
    border-radius: var(--radius-lg, 10px);
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow-xs, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
    border: 1px solid var(--gray-100, #f3f4f6);
}

.act-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #e65100;
    font-size: 1rem;
}

.act-card-body {
    flex: 1;
    min-width: 0;
}

.act-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 0.125rem;
}

.act-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #777;
}

.act-card-category {
    background: #f1f3f5;
    border-radius: 4px;
    padding: 0 0.375rem;
    font-size: 0.7rem;
    color: #666;
}

.act-card-duration {
    color: #555;
}

.act-card-kcal {
    font-weight: 600;
    color: #e65100;
}

.act-card-notes {
    font-size: 0.8rem;
    color: #999;
    margin-top: 0.25rem;
    font-style: italic;
}

.act-card-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.act-edit-btn,
.act-delete-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    font-size: 0.85rem;
    color: #999;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
}
.act-edit-btn:hover {
    color: #495057;
    background: #f1f3f5;
}
.act-delete-btn:hover {
    color: #c92a2a;
    background: #fff5f5;
}

/* Inline edit */
.act-inline-edit {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f0f0f0;
}

.act-edit-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.act-save-edit-btn {
    background: #e65100;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
}
.act-save-edit-btn:hover {
    background: #bf360c;
}

.act-cancel-edit-btn {
    background: #f1f3f5;
    color: #495057;
    border: none;
    border-radius: 6px;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
}
.act-cancel-edit-btn:hover {
    background: #dee2e6;
}

/* PA pill in daily summary strip */
.ds-pa-row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.85rem;
    color: var(--text-dark, #333);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: background-color 0.15s;
}
.ds-pa-row:hover {
    background-color: rgba(230, 81, 0, 0.05);
}

.ds-pa-icon {
    color: #e65100;
    font-size: 1rem;
}

.ds-pa-value {
    font-weight: 600;
    color: #e65100;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .act-form-inline {
        flex-direction: column;
        align-items: stretch;
    }
    .act-duration-input {
        width: 100%;
    }
    .act-summary-bar {
        gap: 1rem;
    }
    .ds-pa-row {
        padding: 0.625rem;
        background: rgba(230, 81, 0, 0.05);
        border-radius: 10px;
    }
    .act-search-dropdown {
        max-height: 260px;
    }
    .act-category-pills {
        gap: 0.25rem;
    }
    .act-category-pill {
        font-size: 0.7rem;
        padding: 0.15rem 0.5rem;
    }
    .act-type-list {
        max-height: 160px;
    }
}

/* ========================================================================
   ACTIVITY ROUTINES - Weekly View, Routine Editor, Badges
   ======================================================================== */

/* Weekly View */
.act-week-view {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 12px 12px;
}

.act-week-day {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    cursor: pointer;
    transition: box-shadow 0.15s;
    overflow: hidden;
}
.act-week-day:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.act-week-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.act-week-day-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #333;
}

.act-week-day-total {
    font-size: 0.75rem;
    color: #e65100;
    font-weight: 600;
}

.act-week-day-slots {
    padding: 6px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.act-week-slot-card {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: #fff3e0;
    border-radius: 12px;
    font-size: 0.75rem;
    color: #333;
}

.act-week-slot-icon {
    color: #e65100;
    font-size: 0.7rem;
}

.act-week-slot-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.act-week-slot-dur {
    color: #777;
    font-size: 0.7rem;
}

.act-week-no-slots {
    color: #999;
    font-size: 0.75rem;
    font-style: italic;
    padding: 4px 0;
}

.act-week-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: #777;
}
.act-week-empty i {
    font-size: 3rem;
    color: #e65100;
    opacity: 0.4;
    margin-bottom: 1rem;
}
.act-week-empty p {
    margin: 0;
    font-size: 1rem;
}
.act-week-empty-sub {
    font-size: 0.85rem;
    color: #999;
    margin-top: 0.5rem !important;
    margin-bottom: 1rem !important;
}

.act-week-footer {
    display: flex;
    justify-content: center;
    padding: 12px;
}

/* View Toggle Buttons */
.act-view-toggle {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    justify-content: center;
}

.act-view-toggle-btn {
    border: 1px solid #e65100;
    color: #e65100;
    background: #fff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}
.act-view-toggle-btn:hover {
    background: #e65100;
    color: #fff;
}
.act-view-toggle-btn-danger {
    border-color: #dc3545;
    color: #dc3545;
}
.act-view-toggle-btn-danger:hover {
    background: #dc3545;
    color: #fff;
}

/* TEE Display */
.act-tee-display {
    text-align: center;
    padding: 8px 12px;
    margin: 0 12px;
    background: #fff3e0;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #e65100;
}
.act-tee-display i {
    margin-right: 4px;
}
.act-tee-note {
    display: block;
    font-size: 0.75rem;
    color: #bf360c;
    margin-top: 2px;
}

/* Routine Badge */
.act-routine-badge {
    display: inline-block;
    background: #e65100;
    color: #fff;
    font-size: 0.65rem;
    padding: 1px 8px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.act-routine-badge-sm {
    display: inline-block;
    background: #fff3e0;
    color: #e65100;
    font-size: 0.6rem;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
    font-weight: 600;
}

/* Routine Editor */
.act-routine-editor {
    padding: 12px;
}

.act-routine-day-section {
    margin-bottom: 8px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    overflow: hidden;
}

.act-routine-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    cursor: default;
}

.act-routine-day-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #333;
}

.act-routine-day-info {
    font-size: 0.7rem;
    color: #999;
}

.act-routine-day-slots {
    padding: 4px 12px;
}

.act-routine-slot {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    border-bottom: 1px solid #f1f3f5;
}
.act-routine-slot:last-child {
    border-bottom: none;
}

.act-routine-slot-icon {
    color: #e65100;
    font-size: 0.85rem;
    width: 20px;
    text-align: center;
}

.act-routine-slot-name {
    flex: 1;
    font-size: 0.8rem;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.act-routine-slot-dur {
    width: 60px;
    padding: 2px 6px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.8rem;
    text-align: center;
}

.act-routine-slot-unit {
    font-size: 0.7rem;
    color: #999;
}

.act-routine-slot-del {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 2px;
    font-size: 0.85rem;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.act-routine-slot-del:hover {
    opacity: 1;
}

.act-routine-add-slot-btn {
    display: block;
    width: 100%;
    padding: 6px;
    border: none;
    background: none;
    color: #e65100;
    font-size: 0.75rem;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
}
.act-routine-add-slot-btn:hover {
    background: #fff3e0;
}

.act-routine-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    align-items: center;
}

.act-routine-delete {
    margin-left: auto;
    background: none;
    border: 1px solid #dc3545;
    color: #dc3545;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
}
.act-routine-delete:hover {
    background: #dc3545;
    color: #fff;
}

/* Slot Picker Overlay */
.act-slot-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.act-slot-picker {
    background: #fff;
    border-radius: 14px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.act-slot-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    font-size: 0.95rem;
}

.act-slot-picker-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #777;
    padding: 0;
}

.act-slot-picker .act-search-input {
    margin: 8px 12px;
    width: calc(100% - 24px);
}

.act-slot-picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px;
    max-height: 50vh;
}

.act-slot-picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.85rem;
    transition: background 0.1s;
}
.act-slot-picker-item:hover {
    background: #f8f9fa;
}
.act-slot-picker-item.selected {
    background: #fff3e0;
    border-left: 3px solid #e65100;
}
.act-slot-picker-item i {
    color: #e65100;
    width: 20px;
    text-align: center;
}

.act-slot-picker-dur {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-top: 1px solid #e9ecef;
    font-size: 0.85rem;
}
.act-slot-picker-dur input {
    width: 70px;
    padding: 4px 8px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    text-align: center;
}

/* Mobile responsive - routine additions */
@media (max-width: 768px) {
    .act-week-slot-card {
        font-size: 0.7rem;
        padding: 2px 6px;
    }
    .act-week-slot-name {
        max-width: 80px;
    }
    .act-routine-slot-name {
        max-width: 120px;
    }
    .act-routine-actions {
        flex-wrap: wrap;
    }
    .act-slot-picker {
        width: 95%;
        max-height: 85vh;
    }
}

/* ==================== Garmin Device Card ==================== */
.garmin-status-card {
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: #fff;
    transition: border-color 0.2s;
}
.garmin-status-card.garmin-connected {
    border-color: #4CAF50;
    border-left: 4px solid #4CAF50;
}
.garmin-status-card.garmin-disconnected {
    border-color: #dee2e6;
}
.garmin-status-card.garmin-loading {
    border-color: #dee2e6;
}
.garmin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.garmin-device-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}
.garmin-device-info i.bi-smartwatch {
    font-size: 1.3rem;
    color: #495057;
}
.garmin-connected .garmin-device-info i.bi-smartwatch {
    color: #4CAF50;
}
.garmin-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 0.5rem;
    vertical-align: middle;
}
.garmin-badge-active {
    background: #e8f5e9;
    color: #2e7d32;
}
.garmin-badge-error {
    background: #fce4ec;
    color: #c62828;
}
.garmin-detail-line {
    font-size: 0.82rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}
.garmin-detail-line i {
    margin-right: 0.3rem;
}
.garmin-error-line {
    font-size: 0.8rem;
    color: #c62828;
    margin-bottom: 0.5rem;
}
.garmin-error-line i {
    margin-right: 0.25rem;
}
.garmin-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.garmin-actions .btn {
    flex: 1;
    font-size: 0.8rem;
}
.garmin-connect-intro p {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 0.75rem;
}
.garmin-login-form {
    margin-top: 0.5rem;
}
.garmin-connect-note {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 0.75rem;
}
.garmin-connect-note i {
    margin-right: 0.25rem;
    color: #4CAF50;
}

/* Spinner animation for Garmin buttons */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}

/* ==================== Dashboard Garmin Section ==================== */
.dashboard-garmin-banner {
    text-align: center;
    padding: 1.5rem 1rem;
    border: 1px dashed #dee2e6;
    border-radius: 12px;
    margin-top: 1rem;
    background: #f8f9fa;
}
.dashboard-garmin-banner i {
    font-size: 2rem;
    color: #6c757d;
    display: block;
    margin-bottom: 0.5rem;
}
.dashboard-garmin-banner p {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 0.75rem;
}
.dashboard-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e0e0e0;
}
.dashboard-section-title i {
    margin-right: 0.4rem;
}

/* =============================================================================
   GLUCOSE REALTIME OVERLAY
   ============================================================================= */

/* Glucose overlay reuses .dashboard-overlay / .dashboard-header / .dashboard-content
   classes. Only the close-button hover color is glucose-specific. */
.glucose-overlay .close-btn:hover {
    color: #f5a623;
    background-color: rgba(245, 166, 35, 0.1);
}

/* Hero card - current glucose value */
.glucose-hero {
    text-align: center;
    padding: 1.25rem 1rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 1rem;
}
.glucose-hero-main {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.25rem;
}
.glucose-hero-value {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
}
.glucose-hero-unit {
    font-size: 1rem;
    color: #6c757d;
    margin-left: 0.15rem;
}
.glucose-hero-trend {
    font-size: 2rem;
    margin-left: 0.35rem;
}
.glucose-hero-secondary {
    margin-top: 0.25rem;
}
.glucose-hero-mmol {
    font-size: 0.9rem;
    color: #999;
}
.glucose-hero-time {
    font-size: 0.85rem;
    color: #999;
    margin-top: 0.35rem;
}
.glucose-hero-status {
    margin-top: 0.5rem;
}

/* Color states */
.glucose-normal { color: #4CAF50; }
.glucose-high   { color: #e74c3c; }
.glucose-low    { color: #3498db; }

/* Status badges */
.glucose-badge-normal,
.glucose-badge-high,
.glucose-badge-low {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}
.glucose-badge-normal { background: #e8f5e9; color: #2e7d32; }
.glucose-badge-high   { background: #fce4ec; color: #c62828; }
.glucose-badge-low    { background: #e3f2fd; color: #1565c0; }

/* Time range for glucose (reuse dashboard pattern) */
.glucose-time-range {
    display: flex;
    justify-content: center;
    gap: 0.375rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    background: var(--gray-100, #f3f4f6);
    border-radius: var(--radius-full, 9999px);
    padding: 0.25rem;
}
.glucose-time-range .time-btn {
    border: none;
    background: transparent;
    color: #6c757d;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full, 9999px);
    cursor: pointer;
    transition: all 0.2s;
}
.glucose-time-range .time-btn:hover {
    color: #333;
    background: rgba(0, 0, 0, 0.05);
}
.glucose-time-range .time-btn.active,
.glucose-daily-time-range .time-btn.active {
    background: white;
    color: #f5a623;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Daily summary time range (reuse glucose pattern) */
.glucose-daily-time-range {
    display: flex;
    justify-content: center;
    gap: 0.375rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    background: var(--gray-100, #f3f4f6);
    border-radius: var(--radius-full, 9999px);
    padding: 0.25rem;
}
.glucose-daily-time-range .time-btn {
    border: none;
    background: transparent;
    color: #6c757d;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full, 9999px);
    cursor: pointer;
    transition: all 0.2s;
}
.glucose-daily-time-range .time-btn:hover {
    color: #333;
    background: rgba(0, 0, 0, 0.05);
}

/* Taller chart for glucose realtime */
.glucose-chart-container {
    height: 280px !important;
}
@media (min-width: 768px) {
    .glucose-chart-container {
        height: 350px !important;
    }
}

/* Daily summary strip glucose indicator */
.ds-glucose-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 6px;
    border-radius: 8px;
    transition: background 0.2s;
}
.ds-glucose-row:hover {
    background: rgba(245, 166, 35, 0.1);
}
.ds-glucose-value {
    font-weight: 600;
}
.ds-glucose-trend {
    font-size: 1rem;
}

/* Daily summary strip heart rate indicator */
.ds-hr-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 6px;
    border-radius: 8px;
    transition: background 0.2s;
}
.ds-hr-row:hover {
    background: rgba(244, 67, 54, 0.1);
}
.ds-hr-value {
    font-weight: 600;
    color: #F44336;
}
.ds-hr-unit {
    font-size: 0.7rem;
    color: #999;
}

/* =============================================================================
   FAVORITES - Save Buttons
   ============================================================================= */

/* Star button on dish cards */
.btn-save-dish-favorite {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 0.5rem;
    margin-right: 0.5rem;
}

.btn-save-dish-favorite:hover {
    background: rgba(255, 193, 7, 0.25);
}

.btn-save-dish-favorite:active {
    transform: scale(0.95);
}

.btn-save-dish-favorite i {
    font-size: 1rem;
    pointer-events: none;
}

.btn-save-dish-favorite.saved {
    color: #ffc107;
}

.btn-save-dish-favorite.saved i::before {
    content: "\f005";
    font-weight: 900;
}

@media (max-width: 576px) {
    .btn-save-dish-favorite {
        width: 44px;
        height: 44px;
    }

    .btn-save-dish-favorite i {
        font-size: 1.1rem;
    }
}

/* Save meal as favorite star button (in meal card, Level 1) */
.btn-save-meal-favorite {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #ffc107;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-save-meal-favorite:hover {
    background: rgba(255, 193, 7, 0.15);
}

.btn-save-meal-favorite:active {
    transform: scale(0.9);
}

.btn-save-meal-favorite i {
    font-size: 1rem;
    pointer-events: none;
}

/* =============================================================================
   FAVORITES - Management Overlay
   ============================================================================= */

/* Favorites tab in diary overlay */
.favorites-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 193, 7, 0.1);
    color: #e6a800;
    border: 1.5px solid rgba(255, 193, 7, 0.3);
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.favorites-tab-btn:hover,
.favorites-tab-btn.active {
    background: linear-gradient(135deg, #e6a800 0%, #ffc107 100%);
    color: white;
    border-color: transparent;
}

.favorites-tab-btn i {
    font-size: 0.9rem;
}

/* Favorites section toggles */
.favorites-section-toggle {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
}

.favorites-section-toggle button {
    flex: 1;
    padding: 0.5rem;
    border: 1.5px solid #dee2e6;
    border-radius: 12px;
    background: white;
    font-weight: 600;
    font-size: 0.85rem;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
}

.favorites-section-toggle button.active {
    background: linear-gradient(135deg, #8B0000 0%, #DC143C 100%);
    color: white;
    border-color: transparent;
}

/* Favorites search */
.favorites-search {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
}

.favorites-search input {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 1.5px solid #dee2e6;
    border-radius: 12px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.favorites-search input:focus {
    border-color: #ffc107;
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.15);
}

/* Favorite card */
.favorite-card {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.15s ease;
}

.favorite-card:hover {
    background: #f8f9fa;
}

.favorite-card:active {
    background: #f0f0f0;
}

.favorite-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 0.75rem;
    font-size: 1.2rem;
}

.favorite-card-icon.dish {
    background: rgba(139, 0, 0, 0.1);
    color: #8B0000;
}

.favorite-card-icon.meal {
    background: rgba(255, 193, 7, 0.15);
    color: #e6a800;
}

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

.favorite-card-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.favorite-card-meta {
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.15rem;
}

.favorite-card-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.favorite-card .btn-rename-favorite {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #6c757d;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.favorite-card .btn-rename-favorite:hover {
    background: rgba(108, 117, 125, 0.15);
}

.favorite-card .btn-rename-favorite i {
    font-size: 0.85rem;
    pointer-events: none;
}

.favorite-card .btn-delete-favorite {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #dc3545;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.favorite-card .btn-delete-favorite:hover {
    background: rgba(220, 53, 69, 0.15);
}

.favorite-card .btn-delete-favorite i {
    font-size: 0.9rem;
    pointer-events: none;
}

.favorite-card.deleting {
    opacity: 0.5;
    pointer-events: none;
}

/* Favorite detail view */
.favorite-detail-header {
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

.favorite-detail-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 0.25rem;
}

.favorite-detail-name input {
    width: 100%;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    padding: 0.25rem 0;
    outline: none;
    transition: border-color 0.2s;
}

.favorite-detail-name input:focus {
    border-bottom-color: #ffc107;
}

.favorite-detail-quantity {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: #888;
}

.favorite-detail-quantity input {
    width: 60px;
    border: 1.5px solid #dee2e6;
    border-radius: 8px;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    text-align: center;
    outline: none;
}

.favorite-detail-quantity input:focus {
    border-color: #ffc107;
}

/* Favorite food list */
.favorite-food-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f5f5f5;
}

.favorite-food-name {
    flex: 1;
    font-size: 0.9rem;
    color: #333;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.favorite-food-qty {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.favorite-food-qty input {
    width: 55px;
    border: 1.5px solid #dee2e6;
    border-radius: 8px;
    padding: 0.2rem 0.4rem;
    font-size: 0.85rem;
    text-align: center;
    outline: none;
}

.favorite-food-qty input:focus {
    border-color: #ffc107;
}

.favorite-food-qty span {
    font-size: 0.8rem;
    color: #888;
}

.favorite-food-item .btn-remove-food {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #dc3545;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    margin-left: 0.25rem;
}

.favorite-food-item .btn-remove-food:hover {
    background: rgba(220, 53, 69, 0.15);
}

.favorite-food-item .btn-remove-food i {
    font-size: 0.85rem;
    pointer-events: none;
}

/* Favorites empty state */
.favorites-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: #aaa;
}

.favorites-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #ddd;
}

.favorites-empty p {
    font-size: 0.95rem;
    margin: 0;
}

/* Favorite detail action buttons */
.favorite-detail-actions {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid #eee;
}

.favorite-detail-actions .btn-log-favorite {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, #8B0000 0%, #DC143C 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.favorite-detail-actions .btn-log-favorite:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(139, 0, 0, 0.3);
}

.favorite-detail-actions .btn-delete-favorite-detail {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1.5px solid rgba(220, 53, 69, 0.3);
    background: transparent;
    color: #dc3545;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.favorite-detail-actions .btn-delete-favorite-detail:hover {
    background: rgba(220, 53, 69, 0.1);
}

/* =========================================================================
   Patient Favorites Viewer (doctor read-only overlay)
   ========================================================================= */

.patient-favorites-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-50, #f9fafb);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    animation: slideInFromRight 0.3s var(--ease-out, ease-out);
    overflow: hidden;
}

.patient-favorites-overlay.closing {
    animation: slideOutToRight 0.3s ease-in forwards;
}

.patient-favorites-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.pfv-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: white;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.pfv-back-btn {
    border: none;
    background: none;
    font-size: 1.25rem;
    color: #8B0000;
    cursor: pointer;
    padding: 0.25rem;
}

.pfv-title {
    margin: 0;
    font-weight: 700;
    font-size: 1rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pfv-body {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 2rem;
}

.pfv-detail-section {
    background: white;
    margin: 0.75rem;
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.pfv-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #8B0000;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.pfv-ingredient-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f5f5f5;
}

.pfv-ingredient-row:last-child {
    border-bottom: none;
}

.pfv-ingredient-row.pfv-nested {
    padding-left: 1rem;
    font-size: 0.85rem;
}

.pfv-ingredient-name {
    font-size: 0.9rem;
    color: #333;
    flex: 1;
}

.pfv-ingredient-qty {
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    margin-left: 0.5rem;
    white-space: nowrap;
}

.pfv-dish-card {
    background: #fafafa;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.pfv-dish-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
}

.pfv-dish-header:hover {
    background: #f0f0f0;
}

.pfv-dish-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pfv-dish-name i {
    color: #8B0000;
    font-size: 0.85rem;
}

.pfv-dish-toggle {
    color: #999;
    font-size: 0.85rem;
    transition: transform 0.2s;
}

.pfv-dish-ingredients {
    padding: 0 1rem 0.75rem;
}

.pfv-meal-type {
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pfv-notes {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.5;
}

.pfv-list-container {
    flex: 1;
    overflow-y: auto;
}

.favorite-card-qty {
    font-size: 0.75rem;
    color: #999;
    margin-left: 0.25rem;
}

.pfv-card-arrow {
    color: #ccc;
    font-size: 0.85rem;
}

/* =============================================================================
   GARMIN ACTIVITY DIARY
   ============================================================================= */

.garmin-activity-summary {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.garmin-activity-summary .stat-box {
    flex: 1;
    background: white;
    border-radius: 10px;
    padding: 0.625rem 0.5rem;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.garmin-activity-summary .stat-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-800, #1f2937);
}
.garmin-activity-summary .stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--gray-500, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.garmin-activity-filter-pills {
    display: flex;
    gap: 0.375rem;
    overflow-x: auto;
    padding: 0 0 0.75rem 0;
    margin-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.garmin-activity-filter-pills::-webkit-scrollbar { display: none; }
.garmin-activity-filter-pills .filter-pill {
    flex-shrink: 0;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--gray-200, #e5e7eb);
    background: white;
    color: var(--gray-600, #4b5563);
    border-radius: 9999px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.garmin-activity-filter-pills .filter-pill.active {
    background: var(--pill-color, var(--primary-color, #8B0000));
    color: white;
    border-color: transparent;
}
.garmin-activity-filter-pills .filter-pill i { margin-right: 0.2rem; }

.garmin-activity-card {
    background: white;
    border-radius: 12px;
    padding: 0.875rem;
    margin-bottom: 0.625rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border-left: 3px solid var(--card-accent, #757575);
}
.garmin-activity-card .card-header-row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.5rem;
}
.garmin-activity-card .card-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.garmin-activity-card .card-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.garmin-activity-card .card-title strong {
    font-size: 0.875rem;
    color: var(--gray-800, #1f2937);
}
.garmin-activity-card .card-title .activity-name {
    font-size: 0.75rem;
    color: var(--gray-500, #6b7280);
    margin-left: 0.375rem;
}
.garmin-activity-card .card-date {
    font-size: 0.7rem;
    color: var(--gray-400, #9ca3af);
}
.garmin-activity-card .activity-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}
.garmin-activity-card .metric {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.2rem 0.5rem;
    background: var(--gray-50, #f9fafb);
    border-radius: 6px;
    font-size: 0.72rem;
    color: var(--gray-600, #4b5563);
}
.garmin-activity-card .metric i {
    font-size: 0.7rem;
    opacity: 0.7;
}

.garmin-activity-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-400, #9ca3af);
}
.garmin-activity-empty i {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.75rem;
}
.garmin-activity-empty p {
    font-size: 0.9rem;
}