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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: #2c2c2c;
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex: 1;
    align-items: center;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.header-actions::-webkit-scrollbar {
    height: 4px;
}

.header-actions::-webkit-scrollbar-track {
    background: transparent;
}

.header-actions::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.header-actions::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

header h1 {
    font-size: 28px;
    margin-right: 20px;
}

nav {
    display: flex;
    gap: 10px;
    flex: 1;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.nav-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    white-space: nowrap;
    text-align: center;
    flex: 0 0 auto;
}


.export-btn {
    padding: 10px 20px;
    background: #4a4a4a;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    white-space: nowrap;
    text-align: center;
    flex: 0 0 auto;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.nav-btn.active {
    background: white;
    color: #2c2c2c;
}

.page {
    display: none;
    padding: 30px;
}

.page.active {
    display: block;
}

/* 캘린더 스타일 */
.calendar-container {
    margin-bottom: 30px;
    overflow-x: auto;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-header button {
    padding: 10px 20px;
    background: #4a4a4a;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
}

.calendar-header button:hover {
    background: #2c2c2c;
}

.calendar-header h2 {
    font-size: 24px;
    color: #333;
}

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

.calendar-day {
    aspect-ratio: 1;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 5px;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 80px;
}

.calendar-day .day-number {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 4px;
}

.calendar-day .meal-types {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: center;
    width: 100%;
    margin-top: auto;
}

.calendar-day .meal-type-badge {
    font-size: 9px;
    padding: 2px 4px;
    background: #4a4a4a;
    color: white;
    border-radius: 3px;
    white-space: nowrap;
}

.calendar-day:hover {
    border-color: #4a4a4a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.calendar-day.other-month {
    color: #ccc;
    background: #f5f5f5;
}

.calendar-day.today {
    border-color: #4a4a4a;
    background: #e0e0e0;
    font-weight: bold;
}

.calendar-day.selected {
    background: #4a4a4a;
    color: white;
    border-color: #4a4a4a;
}

.calendar-day-header {
    font-weight: bold;
    text-align: center;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 8px;
}

/* 기록 섹션 */
.record-section {
    margin-top: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 10px;
}

#selected-date-title {
    font-size: 20px;
    margin-bottom: 15px;
    color: #333;
}

.total-calories {
    font-size: 24px;
    font-weight: bold;
    color: #2c2c2c;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    text-align: center;
}

.meal-sections {
    display: grid;
    gap: 15px;
}

.meal-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #4a4a4a;
}

.meal-section h4 {
    margin-bottom: 15px;
    color: #2c2c2c;
    font-size: 18px;
}

.meal-records {
    margin-bottom: 10px;
}

.record-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 5px;
    margin-bottom: 8px;
}

.record-item-info {
    flex: 1;
}

.record-item-info strong {
    color: #333;
}

.record-item-actions {
    display: flex;
    gap: 5px;
}

.record-item-actions button {
    padding: 5px 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
}

.btn-edit {
    background: #4caf50;
    color: white;
}

.btn-delete {
    background: #c82333;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-delete:hover {
    background: #a01e2a;
}

.add-record-btn {
    padding: 8px 15px;
    background: #4a4a4a;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.add-record-btn:hover {
    background: #2c2c2c;
}

/* 음식 등록 페이지 */
.food-form {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

.food-form input,
.food-form select {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
}

.food-form button {
    padding: 12px 30px;
    background: #4a4a4a;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.food-form button:hover {
    background: #2c2c2c;
}

.food-list {
    margin-top: 30px;
}

.food-list-controls {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.food-list-controls button {
    padding: 8px 15px;
    background: #4a4a4a;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.food-list-controls button:hover {
    background: #5a5a5a;
}

.food-list-controls #change-group-btn {
    background: #4a4a4a;
}

.food-list-controls #change-group-btn:hover {
    background: #5a5a5a;
}

.food-group-header {
    margin-top: 20px;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 2px solid #4a4a4a;
}

.food-group-header:first-child {
    margin-top: 0;
}

.food-group-header h4 {
    color: #4a4a4a;
    font-size: 16px;
    font-weight: bold;
}

.food-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    margin-bottom: 10px;
}

.food-item-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.food-item-info input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.food-item-info strong {
    color: #333;
    font-size: 16px;
}

.food-item-actions {
    display: flex;
    gap: 10px;
}

.food-item-actions button {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.btn-change-group {
    background: #2196F3;
    color: white;
}

.btn-change-group:hover {
    background: #1976D2;
}

.food-group-badge {
    margin-left: 10px;
    padding: 2px 8px;
    background: #e3f2fd;
    color: #1976d2;
    border-radius: 12px;
    font-size: 12px;
    font-weight: normal;
}

/* 그룹 관리 모달 */
#group-management-modal .modal-content {
    max-height: 80vh;
    overflow-y: auto;
}

.group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    margin-bottom: 10px;
}

.group-item-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.group-name-display {
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.group-name-edit {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    width: 200px;
}

.group-item-actions {
    display: flex;
    gap: 10px;
}

.btn-edit-group {
    background: #757575;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-edit-group:hover {
    background: #616161;
}

.btn-save-group {
    background: #2196F3;
    color: white;
}

.btn-save-group:hover {
    background: #1976D2;
}

.btn-cancel-edit {
    background: #757575;
    color: white;
}

.btn-cancel-edit:hover {
    background: #616161;
}

.btn-delete-group {
    background: #c82333;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-delete-group:hover {
    background: #a01e2a;
}

/* 집계 페이지 */
.statistics-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

.statistics-controls input {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
}

.statistics-controls button {
    padding: 12px 30px;
    background: #4a4a4a;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    writing-mode: horizontal-tb;
}

.statistics-controls button:hover {
    background: #2c2c2c;
}

.statistics-content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
}

.frequency-section,
.calories-chart-section {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
}

.frequency-item {
    padding: 12px;
    background: white;
    border-radius: 5px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.frequency-item strong {
    color: #333;
}

.frequency-item span {
    color: #2c2c2c;
    font-weight: bold;
}

#calories-chart {
    width: 100%;
    max-width: 100%;
    height: 300px;
    position: relative;
}

.calories-chart-section {
    position: relative;
    height: 350px;
}

/* 모달 스타일 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 15px;
}

.close:hover {
    color: #000;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.modal-content label {
    font-weight: bold;
    color: #333;
}

.modal-content input,
.modal-content select {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
}

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

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.modal-buttons button[type="submit"] {
    background: #4a4a4a;
    color: white;
}

.modal-buttons button[type="submit"]:hover {
    background: #2c2c2c;
}

.cancel-btn {
    background: #ccc;
    color: #333;
}

.cancel-btn:hover {
    background: #bbb;
}

/* 내보내기 버튼 스타일 */
.export-btn:hover {
    background: #2c2c2c;
}

/* 인증 관련 스타일 */
.auth-section, .user-section {
    display: flex;
    gap: 10px;
    align-items: center;
}

.auth-btn {
    padding: 10px 20px;
    background: #4a4a4a;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    white-space: nowrap;
}

.auth-btn:hover {
    background: #2c2c2c;
}

.error-message {
    color: #d32f2f;
    background: #ffebee;
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
}

.success-message {
    color: #2e7d32;
    background: #e8f5e9;
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
}

/* 마이페이지 스타일 */
.mypage-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.user-info-section, .password-change-section, .withdraw-section {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
}

.info-item {
    display: flex;
    gap: 10px;
    margin: 10px 0;
}

.info-item label {
    font-weight: bold;
    min-width: 100px;
}

.password-change-section form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.password-change-section label {
    font-weight: bold;
}

.password-change-section input {
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
}

.danger-btn {
    background: #d32f2f;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.danger-btn:hover {
    background: #b71c1c;
}

/* 관리자 페이지 스타일 */
.admin-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.admin-controls button {
    padding: 10px 20px;
    background: #4a4a4a;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.admin-controls button:hover {
    background: #2c2c2c;
}

.user-list-section {
    overflow-x: auto;
}

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

#user-list-table th,
#user-list-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

#user-list-table th {
    background: #f5f5f5;
    font-weight: bold;
}

#user-list-table tr:hover {
    background: #f9f9f9;
}

.user-checkbox {
    cursor: pointer;
}

/* 내보내기 모달 폼 스타일 */
.export-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.export-form label {
    font-weight: bold;
    color: #333;
}

.export-form select {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
}

@media (max-width: 1024px) {
    body {
        padding: 15px;
    }

    .page {
        padding: 25px;
    }

    header {
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }

    .header-actions {
        width: 100%;
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
    }

    .header-actions::-webkit-scrollbar {
        height: 4px;
    }

    .header-actions::-webkit-scrollbar-track {
        background: transparent;
    }

    .header-actions::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
    }

    .header-actions::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.5);
    }

    nav {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        flex-shrink: 0;
    }

    .nav-btn {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .export-btn {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .auth-section {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        flex-shrink: 0;
    }

    .auth-btn {
        flex-shrink: 0;
        white-space: nowrap;
    }
}

@media (max-width: 768px) {
    .page {
        padding: 20px 15px;
    }

    .calendar-grid {
        min-width: auto;
        gap: 6px;
    }

    .calendar-day {
        min-height: 60px;
        padding: 4px;
    }

    .calendar-day .day-number {
        font-size: 14px;
    }

    .calendar-day .meal-type-badge {
        font-size: 8px;
    }

    .calendar-header h2 {
        font-size: 20px;
    }

    .calendar-header button {
        padding: 8px 12px;
        font-size: 14px;
    }

    .record-section {
        padding: 15px;
    }

    .meal-section {
        padding: 15px;
    }

    .total-calories {
        font-size: 20px;
    }

    .statistics-content {
        grid-template-columns: 1fr;
    }

    .calories-chart-section {
        width: 100%;
    }

    .statistics-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .statistics-controls button,
    .food-form button {
        width: 100%;
    }

    .food-form {
        flex-direction: column;
    }

    #calories-chart {
        width: 100%;
        height: 260px;
    }
}

/* iPhone 13 Pro 및 최신 갤럭시 최적화 */
@media (max-width: 428px) {
    body {
        padding: 0;
        margin: 0;
        overflow-x: hidden;
    }

    .container {
        border-radius: 0;
        margin: 0;
        box-shadow: none;
    }

    header {
        padding: 8px 6px;
        gap: 4px;
        flex-wrap: nowrap;
        align-items: center;
    }

    header h1 {
        font-size: 16px;
        margin-right: 6px;
        flex-shrink: 0;
        line-height: 1.2;
        white-space: nowrap;
    }

    .header-actions {
        width: 100%;
        display: flex;
        flex-wrap: nowrap;
        gap: 3px;
        flex: 1;
        min-width: 0;
        align-items: center;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .header-actions::-webkit-scrollbar {
        display: none;
    }

    nav {
        display: flex;
        flex-wrap: nowrap;
        gap: 3px;
        flex-shrink: 0;
    }

    .nav-btn {
        padding: 5px 8px;
        font-size: 9px;
        min-width: auto;
        width: auto;
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 30px;
        border-radius: 4px;
        line-height: 1.2;
    }

    /* nav 안의 마이페이지 버튼은 항상 숨김 */
    nav .nav-btn[data-page="mypage"] {
        display: none !important;
    }


    #header-mypage-btn {
        padding: 5px 8px;
        font-size: 9px;
        min-width: auto;
        width: auto;
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 30px;
        border-radius: 4px;
        line-height: 1.2;
    }

    .export-btn {
        padding: 5px 8px;
        font-size: 9px;
        min-width: auto;
        width: auto;
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 30px;
        border-radius: 4px;
        line-height: 1.2;
    }

    .auth-section {
        display: flex;
        flex-wrap: nowrap;
        gap: 3px;
        flex-shrink: 0;
    }

    .user-section {
        display: flex;
        flex-wrap: nowrap;
        gap: 3px;
        flex-shrink: 0;
        align-items: center;
    }

    .auth-btn {
        padding: 5px 8px;
        font-size: 9px;
        min-width: auto;
        width: auto;
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 30px;
        border-radius: 4px;
        line-height: 1.2;
    }

    #user-name {
        display: none;
    }

    .page {
        padding: 10px 6px;
    }

    .calendar-container {
        overflow-x: visible;
        margin-bottom: 20px;
    }

    .calendar-grid {
        gap: 2px;
        width: 100%;
        max-width: 100%;
    }

    .calendar-day {
        min-height: 45px;
        padding: 3px;
        border-radius: 4px;
    }

    .calendar-day .day-number {
        font-size: 13px;
    }

    .calendar-day .meal-type-badge {
        font-size: 8px;
        padding: 1px 3px;
    }

    .calendar-header {
        margin-bottom: 12px;
    }

    .calendar-header h2 {
        font-size: 16px;
    }

    .calendar-header button {
        padding: 5px 8px;
        font-size: 14px;
    }
}

/* 작은 화면 (갤럭시 등 360px 이하) */
@media (max-width: 360px) {
    header h1 {
        font-size: 18px;
    }

    .nav-btn, #header-mypage-btn, .export-btn, .auth-btn {
        padding: 4px 8px;
        font-size: 9px;
        min-height: 28px;
    }

    .calendar-day {
        min-height: 40px;
    }

    .calendar-day .day-number {
        font-size: 12px;
    }
}

    .record-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .record-item-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .statistics-controls input {
        width: 100%;
    }

    #calories-chart {
        width: 100%;
        height: 220px;
    }
}



