:root {
    --primary: #4CAF50;
    --primary-dark: #2E7D32;
    --primary-light: #C8E6C9;
    --danger: #ef5350;
    --warning: #FFC107;
    --logged-color: #9FA8DA; /* New color for "Logged but missed goal" */
    --text-dark: #2c3e50;
    --text-light: #546e7a;
    --bg-grad-start: #f1f8e9;
    --bg-grad-end: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--bg-grad-start) 0%, var(--bg-grad-end) 100%);
    padding: 15px;
    max-width: 1000px;
    margin: 0 auto;
    min-height: 100vh;
    color: var(--text-dark);
}

/* --- Components --- */
.card {
    background: white;
    border-radius: 18px;
    padding: 20px 18px;
    margin-bottom: 18px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.02);
    position: relative;
}

h2 {
    font-size: 17px;
    margin-bottom: 16px;
    color: var(--text-dark);
    font-weight: 700;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.header-subtext {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 400;
}

/* ChatGPT Help Link */
.chatgpt-help {
    font-size: 13px;
    color: var(--text-light);
    margin-top: -10px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #eee;
}

.chatgpt-help a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.chatgpt-help a:hover {
    text-decoration: underline;
}

/* --- Layout Grid --- */
.layout-grid {
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .layout-grid {
        display: grid;
        grid-template-columns: 380px 1fr;
        gap: 20px;
        align-items: start;
    }

    .right-column {
        position: sticky;
        top: 20px;
    }
}

/* --- Date Navigation --- */
.date-selector {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 6px;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    margin-bottom: 16px;
    position: relative;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.nav-btn {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.nav-btn:hover {
    background: var(--primary);
    color: white;
}

.date-display-wrapper {
    position: relative;
    text-align: center;
    flex-grow: 1;
}

.date-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    pointer-events: none;
    display: inline;
}

.date-chevron {
    font-size: 9px;
    color: #bbb;
    margin-left: 4px;
    pointer-events: none;
    vertical-align: middle;
}

.today-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0 12px;
    height: 36px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    margin-left: 6px;
    z-index: 2;
    flex-shrink: 0;
}

.today-btn:hover {
    background: var(--primary-dark);
}

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

.date-display-wrapper input[type="date"] {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

/* --- Stats & Progress --- */
.stats-container {
    text-align: center;
    position: relative;
}

.share-btn, .progress-btn {
    position: absolute;
    top: 15px;
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-light);
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    z-index: 10;
}

.share-btn {
    right: 15px;
}

.progress-btn {
    right: 55px;
}

.share-btn:hover, .progress-btn:hover {
    background: #f0f0f0;
    color: var(--primary-dark);
}

/* Streak chip (top-left of stats card) */
.streak-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    background: #fff8e1;
    border: 1px solid #ffe0b2;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    color: #ef6c00;
    padding: 6px 10px;
    border-radius: 14px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: transform 0.15s, background 0.2s;
    z-index: 10;
}

.streak-btn:hover {
    background: #ffe0b2;
}

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

.streak-btn.muted {
    background: #f5f5f5;
    border-color: #eee;
    color: #aaa;
}

.streak-btn #streakCount {
    font-variant-numeric: tabular-nums;
}

/* Goal Input Styles */
.goal-input-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-light);
    padding: 4px 12px;
    border-radius: 8px;
    max-width: 100%;
}

.goal-input {
    width: 45px;
    padding: 0;
    border: none;
    border-bottom: 1px dashed var(--text-light);
    background: transparent;
    text-align: left;
    font-weight: 700;
    font-size: 14px;
    color: var(--text-dark);
    font-family: inherit;
}

.goal-input:focus {
    outline: none;
    border-bottom: 1px solid var(--primary);
    color: var(--primary);
}

/* Goal Type Selector */
.goal-type-selector {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 12px;
}

.goal-type-pill {
    padding: 6px 14px;
    background: #f5f5f5;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: rgba(76, 175, 80, 0.18);
    touch-action: manipulation;
}

.goal-type-pill.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-color: var(--primary);
}

.goal-type-pill:hover {
    background: #e0e0e0;
}

.big-number {
    font-size: 42px;
    font-weight: 800;
    color: var(--primary-dark);
    line-height: 1;
    margin-top: 5px;
}

.big-number.over-limit {
    color: var(--danger);
}

.big-number.under-limit {
    color: var(--danger);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
    margin-top: 8px;
}

.status-text {
    font-weight: 600;
    transition: color 0.3s ease;
}
.status-text.status-good { color: var(--primary-dark); }
.status-text.status-warn { color: #b26a00; }
.status-text.status-bad  { color: var(--danger); }

.progress-bar-bg {
    --goal-pos: 70%; /* MUST stay in sync with GOAL_POS in script.js */
    background: #eef0f2;
    height: 12px;
    border-radius: 6px;
    margin: 24px 0 26px 0; /* room for the Goal label (top) + usual label (bottom) */
    position: relative;
    overflow: visible; /* markers & labels sit outside the track */
}

/* "Beyond goal" zone — the stretch to the right of the goal line.
   Tinted by mode so the meaning of crossing the line is clear at a glance. */
.beyond-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--goal-pos);
    right: 0;
    border-radius: 0 6px 6px 0;
    z-index: 0;
}
.progress-bar-bg.lose .beyond-zone { background: rgba(239, 83, 80, 0.12); }  /* past a ceiling = danger */
.progress-bar-bg.gain .beyond-zone { background: rgba(76, 175, 80, 0.16); }  /* past a target = bonus */

/* Fixed goal line */
.goal-line {
    position: absolute;
    top: -4px;
    bottom: -4px;
    left: var(--goal-pos);
    width: 2px;
    background: #334155;
    transform: translateX(-50%);
    border-radius: 2px;
    z-index: 3;
}
.goal-line-label {
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #334155;
    white-space: nowrap;
}

/* PACE MARKER — your usual intake by this time (a neutral reference, not a status) */
.ghost-marker {
    position: absolute;
    bottom: -7px;
    left: 0;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 6px solid #64748b;
    transform: translateX(-50%);
    z-index: 4;
    transition: left 0.5s ease;
}
.ghost-label {
    position: absolute;
    top: 8px; /* clear the 6px triangle (its border renders below a 0-height box) */
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: #64748b;
    white-space: nowrap;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    width: 0%;
    transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), background 0.4s ease;
    border-radius: 6px;
    /* Visual Pulse for Add Entry */
    position: relative;
    overflow: hidden;
    z-index: 1;
}

/* PULSE ANIMATION CLASS */
.progress-fill.pulse::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.4);
    animation: pulseFlash 0.5s ease-out;
}

@keyframes pulseFlash {
    0% { opacity: 0; transform: scaleX(0); }
    50% { opacity: 1; transform: scaleX(1); }
    100% { opacity: 0; transform: scaleX(1); }
}

.progress-fill.warning {
    background: linear-gradient(90deg, #ff9800, #f57c00);
}

.progress-fill.danger {
    background: linear-gradient(90deg, #ef5350, #c62828);
}

/* SHAKE ANIMATION */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

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

.macro-item {
    background: #f8f9fa;
    padding: 8px 2px;
    border-radius: 10px;
    text-align: center;
}

.macro-val {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-dark);
}

.macro-lbl {
    font-size: 9px;
    color: var(--text-light);
    margin-top: 2px;
    text-transform: uppercase;
}

/* --- Form --- */
.form-group {
    margin-bottom: 14px;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="number"],
input[type="text"],
input[type="time"],
input[type="date"].native-picker {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #edf2f7;
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
}

input.goal-input {
    width: 70px;
    padding: 0;
    border: none;
    border-bottom: 1px dashed var(--text-light);
    border-radius: 0;
}

input:focus {
    outline: none;
    border-color: var(--primary);
}

.pill-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-bottom: 4px;
}

.pill {
    padding: 8px 16px;
    background: #f1f3f4;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: rgba(76, 175, 80, 0.18);
    touch-action: manipulation;
}

.pill:active {
    transform: scale(0.95);
}

.pill.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-color: var(--primary);
}

.btn-primary {
    width: 100%;
    padding: 15px;
    background: var(--primary-dark);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.2);
    transition: transform 0.1s;
}

.btn-primary:active {
    transform: scale(0.97);
}

/* --- Entries List --- */
.entry-item {
    background: white;
    padding: 14px;
    border-radius: 14px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-left: 4px solid var(--primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
    animation: slideIn 0.3s ease;
}

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

.entry-left {
    flex: 1;
    padding-right: 10px;
}

.entry-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.entry-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f1f8e9;
    color: var(--primary-dark);
    text-transform: uppercase;
}

.entry-title {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 14px;
}

.entry-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.entry-cals {
    font-weight: 800;
    font-size: 16px;
    color: var(--primary-dark);
}

.action-btn-group {
    display: flex;
    gap: 6px;
    opacity: 0.6;
}

.icon-btn {
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 5px;
    border-radius: 6px;
}

.copy-link {
    font-size: 11px;
    color: #999;
    cursor: pointer;
    margin-right: 8px;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: rgba(76, 175, 80, 0.18);
    touch-action: manipulation;
}

.copy-link:hover {
    color: #4CAF50;
    text-decoration: underline;
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-light);
    font-size: 14px;
    font-style: italic;
    opacity: 0.7;
}

/* --- Toast & Modals --- */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #323232;
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 380px;
    padding: 24px;
    animation: zoomIn 0.2s;
    max-height: 90vh;
    overflow-y: auto;
}

.progress-modal-content {
    max-width: 600px;
}

@keyframes zoomIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-btns {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-cancel,
.btn-save,
.btn-delete {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}

.btn-cancel {
    background: #f1f3f4;
    color: var(--text-dark);
}

.btn-save {
    background: var(--primary-dark);
    color: white;
}

.btn-delete {
    background: #ffebee;
    color: #d32f2f;
}

.footer-actions {
    margin-top: 15px;
    text-align: center;
    font-size: 12px;
    color: #aaa;
    padding-bottom: 10px;
}

.footer-link {
    cursor: pointer;
    transition: color 0.2s;
    text-decoration: underline;
    /* Android: stop a tap from being interpreted as a text-selection drag. */
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: rgba(76, 175, 80, 0.18);
    touch-action: manipulation;
}

.footer-link:hover {
    color: #666;
}

.separator {
    margin: 0 5px;
    color: #ddd;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
}

.warning-text {
    color: #ef5350;
    font-size: 14px;
    margin-top: 5px;
    margin-bottom: 20px;
}

/* --- Progress Modal Styles --- */
.progress-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.progress-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: rgba(76, 175, 80, 0.18);
    touch-action: manipulation;
}

.progress-tab.active {
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
}

.progress-tab-panel {
    display: none;
}

.progress-tab-panel.active {
    display: block;
}

/* Summary Stats */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 15px;
}

.stat-box {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Calendar Heatmap */
.calendar-legend {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-light);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

#calendarHeatmap {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-top: 15px;
}

.calendar-day {
    aspect-ratio: 1;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
}

.calendar-day:hover {
    transform: scale(1.1);
    z-index: 10;
}

.calendar-day.success {
    background: #4CAF50;
}

.calendar-day.close {
    background: #FFC107;
}

.calendar-day.missed {
    background: #ef5350; /* Hard missed, very low logging */
}

.calendar-day.logged-only {
    background: var(--logged-color); /* Logged but didn't meet goal - No Guilt */
}

.calendar-day.no-data {
    background: #E0E0E0;
    color: #999;
}

/* Chart Styles */
.chart-controls {
    text-align: center;
    margin-bottom: 15px;
}

#chartRange {
    padding: 8px 12px;
    border: 2px solid #edf2f7;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    background: white;
    cursor: pointer;
}

#calorieChart {
    width: 100%;
    height: 300px;
}

/* Confetti Canvas */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

@media (max-width: 600px) {
    .stats-summary {
        grid-template-columns: 1fr;
    }

    #calendarHeatmap {
        gap: 4px;
    }

    .calendar-day {
        font-size: 9px;
    }
}

/* --- Form row (side-by-side) --- */
.form-row {
    display: flex;
    gap: 10px;
}

.form-group-half {
    flex: 1;
    min-width: 0;
}

/* --- Reminder modal --- */
.reminder-preview {
    background: #f8f9fa;
    border: 1px dashed #ddd;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text-dark);
    margin: 4px 0 12px;
    text-align: center;
    line-height: 1.4;
}

.reminder-preview .preview-msg {
    color: var(--text-light);
    font-size: 12px;
    margin-top: 4px;
}

.reminder-status {
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
    margin-bottom: 4px;
}

/* --- Required field marker + label hint --- */
.req {
    color: var(--danger);
    margin-left: 3px;
    font-weight: 700;
}

.label-hint {
    color: #b0bac4;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    margin-left: 2px;
}

/* --- Entry amount badge --- */
.entry-amount {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

/* --- Smart suggestion dropdown --- */
.suggest-wrap {
    position: relative;
}

.suggest-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 50;
    background: #fff;
    border: 2px solid #edf2f7;
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(44, 62, 80, 0.16);
    max-height: 264px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px;
    overscroll-behavior: contain;
}

.suggest-list[hidden] {
    display: none;
}

.suggest-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: rgba(76, 175, 80, 0.18);
    touch-action: manipulation;
}

.suggest-item.active,
.suggest-item:hover {
    background: var(--primary-light);
}

.suggest-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggest-zap {
    margin-right: 4px;
}

.suggest-meta {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

/* "I ate this again" two-tap confirm state */
.copy-link.confirm {
    color: var(--primary-dark);
    font-weight: 700;
    text-decoration: underline;
}

/* --- Range selector (Progress modal) --- */
.range-selector {
    display: flex;
    gap: 4px;
    background: #f5f5f5;
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 14px;
    overflow-x: auto;
}

.range-opt {
    flex: 1;
    text-align: center;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    border-radius: 6px;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: rgba(76, 175, 80, 0.18);
    touch-action: manipulation;
}

.range-opt.active {
    background: white;
    color: var(--primary-dark);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* --- Insights panel --- */
.insight-section {
    margin-bottom: 22px;
}

.insight-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.insight-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
}

.insight-bar-label {
    width: 80px;
    flex-shrink: 0;
    color: var(--text-dark);
}

.insight-bar-track {
    flex: 1;
    height: 12px;
    background: #f0f0f0;
    border-radius: 6px;
    overflow: hidden;
}

.insight-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 6px;
    transition: width 0.4s ease;
}

.insight-bar-fill.brk { background: linear-gradient(90deg, #FFB74D, #FB8C00); }
.insight-bar-fill.lnc { background: linear-gradient(90deg, #66BB6A, #2E7D32); }
.insight-bar-fill.dnr { background: linear-gradient(90deg, #7986CB, #3949AB); }
.insight-bar-fill.snk { background: linear-gradient(90deg, #BA68C8, #8E24AA); }

.insight-bar-val {
    width: 56px;
    flex-shrink: 0;
    text-align: right;
    font-weight: 700;
    font-size: 12px;
    color: var(--text-dark);
    font-variant-numeric: tabular-nums;
}

.weekday-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    align-items: end;
}

.weekday-col {
    text-align: center;
}

.weekday-bar {
    height: 80px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: 4px;
}

.weekday-bar-fill {
    width: 60%;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height 0.4s ease;
}

.weekday-bar-fill.dim {
    background: #e0e0e0;
}

.weekday-lbl {
    font-size: 10px;
    color: var(--text-light);
    font-weight: 600;
}

.weekday-val {
    font-size: 9px;
    color: #aaa;
    margin-top: 1px;
}

.insight-list {
    margin: 0;
    padding-left: 20px;
    font-size: 13px;
    color: var(--text-dark);
    line-height: 1.7;
}

.insight-list li {
    margin-bottom: 2px;
}

.insight-list li .li-meta {
    color: var(--text-light);
    font-size: 11px;
    margin-left: 4px;
}

.insight-empty {
    text-align: center;
    padding: 30px 10px;
    color: var(--text-light);
    font-size: 14px;
    font-style: italic;
}

/* --- Export modal --- */
.export-preview {
    background: #f8f9fa;
    border: 1px dashed #ddd;
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 8px;
    max-height: 180px;
    overflow-y: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    color: var(--text-dark);
    white-space: pre-wrap;
    line-height: 1.45;
}

#exportModal .modal-content {
    max-width: 460px;
}

#exportModal .modal-btns {
    flex-wrap: wrap;
}

#exportModal .modal-btns button {
    min-width: 90px;
}

/* --- Swipe feedback --- */
.swipe-flash {
    animation: swipeFlash 0.35s ease-out;
}

@keyframes swipeFlash {
    0%   { transform: translateX(0); opacity: 1; }
    40%  { transform: translateX(var(--swipe-dir, -8px)); opacity: 0.6; }
    100% { transform: translateX(0); opacity: 1; }
}