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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 16px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 32px;
}

header h1 {
    color: #2c3e50;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.header-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.home-button,
.logout-button {
    display: inline-block;
    color: #5a67d8;
    text-decoration: none;
    padding: 10px 20px;
    background: white;
    border: 2px solid #5a67d8;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-button {
    color: #e53e3e;
    border-color: #e53e3e;
}

.home-button:hover {
    background: #5a67d8;
    color: white;
    transform: translateY(-1px);
}

.logout-button:hover {
    background: #e53e3e;
    color: white;
    transform: translateY(-1px);
}

/* Form Card */
.add-measurement-card,
.measurements-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.add-measurement-card h2,
.measurements-card h2 {
    color: #1a202c;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-measurement-card h2::before {
    content: '';
    width: 4px;
    height: 24px;
    background: #5a67d8;
    border-radius: 2px;
}

.measurements-card h2::before {
    content: '';
    width: 4px;
    height: 24px;
    background: #48bb78;
    border-radius: 2px;
}

/* Form Styles */
.measurement-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.form-field label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #4a5568;
}

.form-field input,
.form-field textarea {
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    background: #f7fafc;
    transition: all 0.2s;
}

.form-field input:focus,
.form-field textarea:focus {
    outline: none;
    border-color: #5a67d8;
    background: white;
}

.form-field textarea {
    resize: vertical;
    font-family: inherit;
}

.submit-btn {
    padding: 14px 28px;
    background: #5a67d8;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    align-self: flex-start;
}

.submit-btn:hover {
    background: #4c51bf;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(90, 103, 216, 0.4);
}

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

/* Table Styles */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: #f7fafc;
    border-bottom: 2px solid #e2e8f0;
}

th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    color: #2d3748;
    font-size: 0.9rem;
    white-space: nowrap;
}

td {
    padding: 14px 12px;
    border-bottom: 1px solid #e2e8f0;
    color: #4a5568;
    font-size: 0.95rem;
}

tbody tr:hover {
    background: #f7fafc;
}

tbody tr:last-child td {
    border-bottom: none;
}

.notes-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Partial measurements styles */
.partial-toggle-row {
    background: #f7fafc !important;
}

.partial-toggle-row td {
    padding: 8px 12px !important;
}

.partial-toggle {
    background: none;
    border: none;
    color: #5a67d8;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    transition: color 0.2s;
}

.partial-toggle:hover {
    color: #4c51bf;
}

.partial-toggle .caret {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.partial-row {
    background: #fafbfc;
}

.partial-row td {
    font-size: 0.9rem;
    color: #718096;
    padding-left: 24px;
}

.partial-row.hidden {
    display: none;
}

.full-row {
    font-weight: 500;
    background: white;
}

.delete-btn {
    background: #fc8181;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.delete-btn:hover {
    background: #f56565;
    transform: scale(1.05);
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #a0aec0;
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

/* Mobile Optimization */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .add-measurement-card,
    .measurements-card {
        padding: 16px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .submit-btn {
        width: 100%;
    }

    .table-container {
        border-radius: 8px;
    }

    th, td {
        padding: 10px 8px;
        font-size: 0.85rem;
    }

    .notes-cell {
        max-width: 150px;
    }

    /* Make table scrollable horizontally on mobile */
    table {
        min-width: 800px;
    }
}

/* Graph Styles */
.graph-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: #f7fafc;
    border-radius: 8px;
}

.graph-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #4a5568;
    user-select: none;
}

.graph-controls input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #5a67d8;
}

.graph-container {
    position: relative;
    height: 400px;
    background: white;
    border-radius: 8px;
    padding: 16px;
}

@media (min-width: 769px) {
    .graph-container {
        height: 700px;
    }
}

/* Focus states for accessibility */
.submit-btn:focus-visible,
.delete-btn:focus-visible,
.home-button:focus-visible,
.logout-button:focus-visible {
    outline: 2px solid #5a67d8;
    outline-offset: 2px;
}

input:focus-visible,
textarea:focus-visible {
    outline: 2px solid #5a67d8;
    outline-offset: -2px;
}

/* Calendar Event Tracker */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 10px;
    background: #f7fafc;
    border-radius: 8px;
}

.calendar-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #2d3748;
}

.month-nav-btn {
    background: #5a67d8;
    color: white;
    border: none;
    border-radius: 6px;
    width: 36px;
    height: 36px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.month-nav-btn:hover {
    background: #4c51bf;
}

.event-counters {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.counter-box {
    flex: 1;
    min-width: 120px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.counter-label {
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.9;
}

.counter-value {
    font-size: 2rem;
    font-weight: 700;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-day {
    aspect-ratio: 1;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: white;
    transition: all 0.2s;
    position: relative;
}

.calendar-day:hover {
    border-color: #5a67d8;
    transform: scale(1.05);
}

.calendar-day.other-month {
    opacity: 0.3;
    cursor: default;
}

.calendar-day.other-month:hover {
    transform: none;
    border-color: #e2e8f0;
}

.calendar-day.today {
    border-color: #5a67d8;
    background: #ebf4ff;
}

.day-number {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2d3748;
}

.day-events {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.event-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
}

.event-badge.e-event {
    background: #48bb78;
}

.event-badge.m-event {
    background: #ed8936;
}

.event-badge.d-event {
    background: #9f7aea;
}

@media (max-width: 768px) {
    .calendar-day {
        font-size: 0.85rem;
    }

    .day-number {
        font-size: 0.8rem;
    }

    .event-badge {
        font-size: 0.65rem;
        padding: 1px 4px;
    }

    .counter-box {
        min-width: 100px;
        padding: 12px;
    }

    .counter-value {
        font-size: 1.5rem;
    }
}

/* Event Modal */
.event-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.event-modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.event-modal-content {
    background-color: white;
    padding: 32px;
    border-radius: 15px;
    max-width: 450px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.event-modal-content h3 {
    margin: 0 0 20px 0;
    color: #2d3748;
    font-size: 1.3rem;
    text-align: center;
}

.event-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.event-control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: #f7fafc;
    border-radius: 12px;
}

.event-type-label {
    font-weight: 600;
    font-size: 1.1rem;
    min-width: 100px;
}

.event-type-label.e-label {
    color: #48bb78;
}

.event-type-label.m-label {
    color: #ed8936;
}

.event-type-label.d-label {
    color: #9f7aea;
}

.event-buttons {
    display: flex;
    align-items: center;
    gap: 16px;
}

.event-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.event-btn.plus-btn {
    background: #48bb78;
    color: white;
}

.event-btn.plus-btn:hover {
    background: #38a169;
    transform: scale(1.1);
}

.event-btn.minus-btn {
    background: #f56565;
    color: white;
}

.event-btn.minus-btn:hover {
    background: #e53e3e;
    transform: scale(1.1);
}

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

.event-btn:disabled:hover {
    transform: none;
}

.event-current {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d3748;
    min-width: 30px;
    text-align: center;
}

.close-modal-btn {
    width: 100%;
    padding: 14px;
    background: #5a67d8;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.close-modal-btn:hover {
    background: #4c51bf;
}
