:root {
    --bg: #0d1117;
    --card-bg: #161b22;
    --card-hover: #1c2128;
    --text-main: #e6edf3;
    --text-secondary: #7d8590;
    --accent-primary: #58a6ff;
    --accent-secondary: #bc8cff;
    --border-color: #30363d;
    
    /* Category colors - softer, more cohesive palette */
    --color-sleep: #58a6ff;
    --color-feeding: #f78166;
    --color-diaper: #ffa657;
    --color-pumping: #bc8cff;
    --color-medicine: #56d364;
    --color-growth: #e3b341;
    --color-temperature: #f85149;
    --color-activity: #79c0ff;
}

* {
    box-sizing: border-box;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text-main);
}

#app {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

header {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
    flex-wrap: wrap;
}

header .baby-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.baby-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.baby-name {
    font-size: 16px;
    font-weight: 600;
}

.baby-selector-container {
    display: inline-block;
}

.baby-selector {
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.baby-selector:hover {
    border-color: var(--accent-primary);
}

.baby-selector:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.nav-btn {
    background: var(--accent-primary);
    color: var(--text-main);
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-menu-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 500;
}

.user-menu-btn:hover {
    background: var(--card-hover);
    border-color: var(--accent-primary);
}

.user-icon {
    font-size: 16px;
}

.user-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: none;
    z-index: 1000;
    overflow: hidden;
}

.user-menu-dropdown.show {
    display: block;
}

.user-menu-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-hover);
}

.user-menu-email {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.user-menu-item:hover {
    background: var(--card-hover);
}

.user-menu-item:active {
    opacity: 0.7;
}

main {
    flex: 1;
    padding: 10px;
    overflow-x: hidden;
    width: 100%;
}

.view {
    display: none;
}
.view.active {
    display: block;
}

/* DASHBOARD -------------------------------------------------------- */
.section-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 14px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.tile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    max-width: 100%;
}

.tile {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    color: var(--text-main);
    font-size: 16px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 70px;
}

.tile.full-width {
    grid-column: 1 / -1;
}

.tile:active {
    transform: scale(0.98);
    background: var(--card-hover);
}

.tile::before {
    content: attr(data-icon);
    font-size: 24px;
    line-height: 1;
    min-width: 28px;
    text-align: center;
}

.tile-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tile-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
}

.tile span.subtitle {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.tile-indicator {
    width: 4px;
    height: 40px;
    border-radius: 2px;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.tile-blue .tile-indicator    { background: var(--color-sleep); }
.tile-orange .tile-indicator  { background: var(--color-feeding); }
.tile-magenta .tile-indicator { background: var(--color-feeding); }
.tile-yellow .tile-indicator  { background: var(--color-diaper); }
.tile-purple .tile-indicator  { background: var(--color-pumping); }
.tile-cyan .tile-indicator    { background: var(--color-medicine); }
.tile-green .tile-indicator   { background: var(--color-growth); }
.tile-pink .tile-indicator    { background: var(--color-temperature); }
.tile-lime .tile-indicator    { background: var(--color-activity); }

.bottom-row {
    margin-top: 0;
}

/* FORMS ------------------------------------------------------------ */
.form-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.back-btn {
    background: none;
    color: var(--accent-primary);
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 0;
    font-weight: 600;
}

.form-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 16px 14px 18px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4);
}

form label {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
}

form input[type="text"],
form input[type="number"],
form input[type="datetime-local"],
form input[type="date"],
form input[type="time"],
form select,
form textarea {
    width: 100%;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.15);
    background: #0b1524;
    color: #fff;
    padding: 8px 10px;
    font-size: 14px;
    margin-bottom: 10px;
}

form textarea {
    resize: vertical;
    min-height: 60px;
}

.radio-row,
.chip-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.chip {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.4);
    font-size: 13px;
    cursor: pointer;
}

.chip.active {
    background: var(--accent-primary);
    color: var(--text-main);
    border-color: var(--accent-primary);
}

.submit-btn {
    width: 100%;
    margin-top: 6px;
    border-radius: 8px;
    border: none;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    background: var(--accent-primary);
    color: var(--text-main);
    transition: all 0.2s ease;
}

.submit-btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.helper-text {
    font-size: 12px;
    opacity: 0.7;
    margin-bottom: 8px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}
.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* LAST EVENT TEXT -------------------------------------------------- */
.tile .last-event {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* FLATPICKR CUSTOM STYLING ----------------------------------------- */
.flatpickr-calendar {
    background: var(--card-bg) !important;
    box-shadow: 0 8px 16px rgba(0,0,0,0.6) !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
    border-radius: 12px !important;
}

.flatpickr-months {
    background: var(--card-bg) !important;
}

.flatpickr-current-month {
    color: var(--text-main) !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
    background: var(--bg) !important;
    color: var(--text-main) !important;
}

.flatpickr-weekdays {
    background: var(--card-bg) !important;
}

.flatpickr-weekday {
    color: var(--text-main) !important;
    opacity: 0.7;
}

.flatpickr-day {
    color: var(--text-main) !important;
}

.flatpickr-day:hover {
    background: rgba(182, 241, 55, 0.2) !important;
    border-color: var(--accent-primary) !important;
}

.flatpickr-day.selected {
    background: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
    color: #000 !important;
}

.flatpickr-day.today {
    border-color: var(--accent-primary) !important;
}

.flatpickr-time input {
    background: var(--bg) !important;
    color: var(--text-main) !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
}

.flatpickr-time .flatpickr-time-separator,
.flatpickr-time .flatpickr-am-pm {
    color: var(--text-main) !important;
}

.flatpickr-am-pm {
    background: var(--bg) !important;
    color: var(--text-main) !important;
}

.flatpickr-am-pm:hover {
    background: rgba(182, 241, 55, 0.2) !important;
}

.numInputWrapper:hover {
    background: rgba(182, 241, 55, 0.1) !important;
}

.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
    color: var(--accent-primary) !important;
}

.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg {
    fill: var(--text-main) !important;
}

.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: var(--accent-primary) !important;
}

/* TIMELINE PAGE ----------------------------------------------------- */
.timeline-summary {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.summary-stat {
    flex: 1;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 14px 12px;
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 11px;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.view-toggle-btn {
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-left: auto;
}

.view-toggle-btn:hover {
    background: rgba(182, 241, 55, 0.1);
    border-color: var(--accent-primary);
}

.timeline-section {
    margin-bottom: 20px;
}

.timeline-section-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 10px 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.timeline-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-item {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.timeline-item-time {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-primary);
    white-space: nowrap;
}

.timeline-item-details {
    flex: 1;
}

.timeline-item-main {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}

.timeline-item-sub {
    font-size: 12px;
    opacity: 0.7;
}

.timeline-container {
    position: relative;
    padding-left: 70px;
}

.timeline-hour {
    margin-bottom: 30px;
}

.timeline-hour-label {
    position: absolute;
    left: 0;
    width: 60px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-primary);
    text-align: right;
    padding-right: 10px;
}

.timeline-events {
    border-left: 2px solid rgba(182, 241, 55, 0.3);
    padding-left: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-event {
    position: relative;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 10px 12px;
}

.timeline-event::before {
    content: '';
    position: absolute;
    left: -22px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--accent-primary);
    background: var(--bg);
}

.timeline-event-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.timeline-event-icon {
    font-size: 16px;
}

.timeline-event-type {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    opacity: 0.7;
    letter-spacing: 0.5px;
}

.timeline-event-time {
    font-size: 11px;
    opacity: 0.6;
    margin-left: auto;
}

.timeline-event-details {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}

.timeline-event-sub {
    font-size: 12px;
    opacity: 0.7;
}

/* Event type colors */
.timeline-event.event-sleep { border-left: 3px solid var(--tile-blue); }
.timeline-event.event-feeding { border-left: 3px solid var(--tile-orange); }
.timeline-event.event-diaper { border-left: 3px solid var(--tile-yellow); }
.timeline-event.event-pumping { border-left: 3px solid var(--tile-purple); }
.timeline-event.event-medicine { border-left: 3px solid var(--tile-cyan); }
.timeline-event.event-temperature { border-left: 3px solid var(--tile-pink); }
.timeline-event.event-activity { border-left: 3px solid var(--tile-lime); }

/* Weekly Timeline View */
.weekly-timeline-container {
    padding-left: 0;
}

.timeline-day {
    margin-bottom: 24px;
    background: var(--card-bg);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.timeline-day-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.timeline-day-events {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.timeline-compact-event {
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.timeline-compact-event .compact-time {
    font-weight: 600;
    color: var(--accent-primary);
    white-space: nowrap;
    min-width: 60px;
}

.timeline-compact-event .compact-icon {
    font-size: 16px;
}

.timeline-compact-event .compact-details {
    flex: 1;
    opacity: 0.9;
}

/* Monthly Timeline View */
.monthly-timeline-container {
    padding-left: 0;
}

.timeline-week {
    margin-bottom: 24px;
    background: var(--card-bg);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.timeline-week-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 10px;
}

.timeline-week-summary {
    font-size: 12px;
    opacity: 0.8;
    padding: 10px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    margin-bottom: 12px;
    line-height: 1.5;
}

.timeline-week-events {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.timeline-month-day {
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    opacity: 0.9;
}

/* WEIGHT INPUT GROUP ----------------------------------------------- */
.weight-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.weight-field {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.weight-field input {
    flex: 1;
    margin-bottom: 0 !important;
}

.weight-unit {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    opacity: 0.7;
    white-space: nowrap;
}

/* INSIGHTS PAGE ---------------------------------------------------- */
.insights-container {
    padding-bottom: 20px;
}

.insights-header {
    margin-bottom: 20px;
}

.insights-title h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 4px 0;
}

.insights-title .subtitle {
    font-size: 14px;
    opacity: 0.7;
    margin: 0;
}

.insights-controls {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    align-items: center;
}

.insights-controls .form-control {
    flex: 1;
    margin-bottom: 0;
    max-width: 200px;
}

.insights-controls .btn {
    white-space: nowrap;
}

.insights-period {
    margin-top: 8px;
    font-size: 12px;
    opacity: 0.6;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.summary-card {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4);
}

.summary-card .card-icon {
    font-size: 32px;
    line-height: 1;
}

.summary-card .card-content {
    flex: 1;
}

.summary-card .card-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1.2;
}

.summary-card .card-label {
    font-size: 11px;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Insight Sections */
.insight-section {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4);
}

.insight-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.insight-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 16px 0 8px 0;
    opacity: 0.9;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-item {
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.stat-item .stat-label {
    font-size: 11px;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.stat-item .stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-primary);
}

/* Insights List */
.insights-list {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 12px;
}

.insights-list ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.insights-list li {
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 6px;
    opacity: 0.9;
}

.no-insights {
    font-size: 13px;
    opacity: 0.6;
    text-align: center;
    padding: 12px;
    margin: 0;
}

.no-data {
    font-size: 13px;
    opacity: 0.6;
    text-align: center;
    padding: 20px;
    margin: 0;
}

/* Recommendations */
.recommendations-section {
    background: linear-gradient(135deg, rgba(182, 241, 55, 0.1), rgba(182, 241, 55, 0.05));
    border: 1px solid rgba(182, 241, 55, 0.2);
}

.recommendations-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recommendation-item {
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border-left: 3px solid transparent;
}

.recommendation-item.priority-high {
    border-left-color: #ff4444;
    background: rgba(255, 68, 68, 0.1);
}

.recommendation-item.priority-medium {
    border-left-color: #ffaa00;
    background: rgba(255, 170, 0, 0.1);
}

.recommendation-item.priority-low {
    border-left-color: #44ff44;
    background: rgba(68, 255, 68, 0.1);
}

.recommendation-item .rec-icon {
    font-size: 20px;
    line-height: 1;
}

.recommendation-item .rec-content {
    flex: 1;
}

.recommendation-item .rec-category {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    opacity: 0.7;
    margin-bottom: 4px;
}

.recommendation-item .rec-message {
    font-size: 13px;
    line-height: 1.5;
    opacity: 0.95;
}

/* Loading State */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.loading-spinner > div {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(182, 241, 55, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-container p {
    font-size: 14px;
    opacity: 0.7;
    margin: 0;
}

/* Error State */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.error-container h2 {
    font-size: 20px;
    margin: 0 0 12px 0;
}

.error-container p {
    font-size: 14px;
    opacity: 0.7;
    margin: 0 0 20px 0;
}

.error-container .btn {
    background: var(--accent-primary);
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn-secondary {
    background: var(--card-bg) !important;
    color: var(--text-main) !important;
    border: 1px solid rgba(255,255,255,0.2) !important;
}

.btn-secondary:hover {
    background: rgba(182, 241, 55, 0.1) !important;
    border-color: var(--accent-primary) !important;
}

/* Responsive adjustments for insights */
@media (max-width: 380px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .insights-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .insights-controls .form-control {
        max-width: 100%;
    }
}

/* AI SUMMARY CARD -------------------------------------------------- */
#ai-summary-section {
    margin-bottom: 20px;
}

.ai-summary-card {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.15), rgba(188, 140, 255, 0.1));
    border: 1px solid rgba(88, 166, 255, 0.3);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.1);
    cursor: pointer;
    user-select: none;
}

.ai-summary-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.ai-summary-icon {
    font-size: 20px;
}

.ai-summary-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-primary);
}

.ai-summary-period {
    font-size: 11px;
    opacity: 0.7;
    background: rgba(0,0,0,0.3);
    padding: 4px 10px;
    border-radius: 999px;
}

.ai-summary-toggle {
    margin-left: auto;
    font-size: 12px;
    opacity: 0.7;
    transition: transform 0.3s ease;
}

.ai-summary-card.expanded .ai-summary-toggle {
    transform: rotate(180deg);
}

.ai-summary-content {
    font-size: 14px;
    line-height: 1.6;
    opacity: 0.95;
    margin-bottom: 12px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.ai-summary-content.collapsed {
    max-height: 1.6em;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-summary-content.expanded {
    max-height: 1000px;
}

.ai-summary-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.ai-summary-age {
    font-size: 11px;
    opacity: 0.6;
}

.ai-summary-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.ai-summary-link:hover {
    text-decoration: underline;
}

/* TIMER CONTROL SECTION -------------------------------------------- */
.timer-control-section {
    margin-bottom: 20px;
}

/* PREDICTIONS SECTION ---------------------------------------------- */
.predictions-section {
    margin-bottom: 12px;
}

.predictions-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
}

.predictions-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.predictions-icon {
    font-size: 14px;
}

.predictions-title {
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.predictions-beta {
    background: rgba(188, 140, 255, 0.2);
    color: var(--accent-secondary);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
}

.predictions-content {
    display: flex;
    flex-direction: row;
    gap: 8px;
}

.prediction-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    flex: 1;
    min-width: 0;
}

.prediction-emoji {
    font-size: 18px;
    flex-shrink: 0;
}

.prediction-text {
    flex: 1;
    min-width: 0;
}

.prediction-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
}

.prediction-value {
    font-size: 12px;
    color: var(--text-main);
    font-weight: 600;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prediction-item.low-confidence {
    opacity: 0.7;
}

.prediction-item.low-confidence .prediction-value {
    color: var(--text-secondary);
}

.prediction-item.overdue {
    border-color: rgba(244, 67, 54, 0.3);
    background: rgba(244, 67, 54, 0.05);
}

.prediction-item.overdue .prediction-value {
    color: #f44336;
}

.timer-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
}

.timer-start-btn {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.2), rgba(88, 166, 255, 0.1));
    border: 2px solid var(--accent-primary);
    color: var(--accent-primary);
}

.timer-start-btn:hover {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.3), rgba(88, 166, 255, 0.15));
    transform: translateY(-2px);
}

.timer-active-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(255, 170, 0, 0.2), rgba(255, 170, 0, 0.1));
    border: 2px solid #ffaa00;
    border-radius: 12px;
    animation: pulse 2s ease-in-out infinite;
}

.timer-display {
    display: flex;
    align-items: center;
    gap: 10px;
}

.timer-icon {
    font-size: 20px;
}

.timer-duration {
    font-size: 20px;
    font-weight: 700;
    color: #ffaa00;
}

.timer-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.timer-cancel-btn {
    padding: 6px 12px;
    background: rgba(255,255,255,0.1);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    opacity: 0.8;
}

.timer-cancel-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
    opacity: 1;
}

.timer-stop-btn {
    padding: 10px 24px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.timer-stop-btn:hover {
    background: #ff2222;
    transform: scale(1.05);
}

/* Timer Stop Modal */
.timer-modal-content {
    max-width: 400px;
}

.timer-modal-body {
    padding: 20px;
}

.timer-modal-duration {
    text-align: center;
    font-size: 16px;
    margin-bottom: 20px;
    color: var(--text);
}

.timer-modal-duration strong {
    color: var(--accent-primary);
}

.timer-record-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.timer-record-btn {
    padding: 20px;
    background: var(--card-bg);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    transition: all 0.2s;
}

.timer-record-btn:hover {
    background: rgba(88, 166, 255, 0.1);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.timer-record-icon {
    font-size: 32px;
}

/* INSIGHTS FRESHNESS INDICATOR ------------------------------------- */
.insights-freshness {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    margin-top: 12px;
    margin-bottom: 12px;
}

.insights-freshness .freshness-icon {
    font-size: 16px;
    line-height: 1;
}

.insights-freshness .freshness-text {
    font-size: 13px;
    font-weight: 500;
}

.insights-freshness .freshness-detail {
    font-size: 11px;
    opacity: 0.6;
    margin-left: 4px;
}

.insights-freshness.freshness-fresh {
    background: rgba(68, 255, 68, 0.15);
    border: 1px solid rgba(68, 255, 68, 0.3);
}

.insights-freshness.freshness-stale {
    background: rgba(255, 170, 0, 0.15);
    border: 1px solid rgba(255, 170, 0, 0.3);
}

.insights-freshness.freshness-stale .freshness-icon {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* TIMELINE PAGE ----------------------------------------------------- */
.timeline-controls {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.timeline-period-btn {
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.timeline-period-btn:hover {
    background: rgba(182, 241, 55, 0.1);
    border-color: var(--accent-primary);
}

.timeline-period-btn.active {
    background: var(--accent-primary);
    color: #000;
    border-color: var(--accent-primary);
}

.timeline-view-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding: 0 4px;
}

.timeline-view-toggle .view-toggle-btn {
    flex: 1;
    margin-left: 0;
    transition: all 0.2s ease;
}

.timeline-view-toggle .view-toggle-btn.active {
    background: var(--accent-primary);
    color: #000;
    border-color: var(--accent-primary);
}

/* PWA Install Prompt */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #58a6ff 0%, #4a8fd8 100%);
    color: white;
    padding: 16px 20px;
    display: none;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    animation: slideUp 0.3s ease-out;
}

.pwa-install-banner.show {
    display: flex;
}

.pwa-install-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.pwa-install-icon {
    font-size: 32px;
}

.pwa-install-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.pwa-install-text p {
    margin: 4px 0 0 0;
    font-size: 13px;
    opacity: 0.9;
}

.pwa-install-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.pwa-install-btn {
    background: white;
    color: #58a6ff;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pwa-install-btn:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
}

.pwa-install-dismiss {
    background: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.pwa-install-dismiss:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
}

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

@media (max-width: 600px) {
    .pwa-install-banner {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .pwa-install-actions {
        width: 100%;
    }
    
    .pwa-install-btn,
    .pwa-install-dismiss {
        flex: 1;
    }
}
