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

body {
    font-family: 'Segoe UI', '맑은 고딕', sans-serif;
    background: #ffffff;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 리본 메뉴 이미지 컨테이너 */
.ribbon-image-container {
    width: 100%;
    height: auto;
    background: #f3f2f1;
    border-bottom: 1px solid #d1d1d1;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    overflow: hidden;
    position: relative;
}

.ribbon-image {
    width: 100%;
    height: auto;
    display: block;
    max-width: none;
}

/* 헤더 기능 오버레이 - 타이틀바 위치에 정확히 맞춤 */
.header-overlay {
    position: absolute;
    top: 0;
    right: 0;
    height: 30px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 140px 0 20px; /* 윈도우 컨트롤 버튼 공간 확보 */
    background: transparent;
    z-index: 200;
}

.header-left {
    display: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.last-update-time, .refresh-control, .auth-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.update-time-label {
    font-size: 10px;
    color: #323130;
    font-weight: 400;
    background: rgba(255, 255, 255, 0.9);
    padding: 1px 4px;
    border-radius: 2px;
    border: 1px solid rgba(209, 209, 209, 0.5);
}

.refresh-label {
    display: none; /* 공간 절약 */
}

.excel-icon-button {
    width: 20px;
    height: 20px;
    border: 1px solid rgba(138, 136, 134, 0.8);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #323130;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.excel-icon-button:hover {
    background: rgba(237, 235, 233, 0.95);
    border-color: rgba(96, 94, 92, 0.8);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.excel-icon-button:active {
    background: rgba(210, 208, 206, 0.95);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
    transform: translateY(0);
}

.excel-login-btn {
    padding: 2px 8px;
    border: 1px solid rgba(138, 136, 134, 0.8);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 2px;
    cursor: pointer;
    font-size: 10px;
    color: #323130;
    font-weight: 500;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.excel-login-btn:hover {
    background: rgba(237, 235, 233, 0.95);
    border-color: rgba(96, 94, 92, 0.8);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.premium-page-link {
    padding: 2px 8px;
    border: 1px solid rgba(138, 136, 134, 0.8);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 2px;
    font-size: 10px;
    color: #1e40af;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.premium-page-link:hover {
    background: rgba(237, 235, 233, 0.95);
    border-color: rgba(96, 94, 92, 0.8);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* 회전 애니메이션 */
.excel-icon-button.rotating {
    animation: rotate 1s linear;
}

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

/* 반응형 디자인 */
@media (max-width: 768px) {
    .header-overlay {
        padding: 0 80px 0 10px; /* 모바일에서 윈도우 컨트롤 버튼 공간 줄임 */
    }

    .last-update-time {
        display: none;
    }

    .header-right {
        gap: 6px;
    }
}

/* 워크시트 영역 */
.worksheet-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #ffffff;
}

/* 열 헤더 */
.column-headers {
    display: flex;
    height: 20px;
    background: #f3f2f1;
    border-bottom: 1px solid #d1d1d1;
    position: sticky;
    top: 0;
    z-index: 100;
    overflow: hidden; /* 스크롤바 제거 */
}

.select-all-corner {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    border-right: 1px solid #d1d1d1;
    background: #f3f2f1;
    cursor: pointer;
    flex-shrink: 0;
}

.column-header {
    min-width: 80px;
    width: 80px;
    border-right: 1px solid #e1e1e1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #323130;
    cursor: pointer;
    background: #f3f2f1;
    font-weight: 500;
    flex-shrink: 0;
}

/* 반응형 헤더 - 화면 크기에 따라 헤더 개수 조정 */
@media (max-width: 1400px) {
    .column-header:nth-child(n+19) {
        display: none;
    }
}
@media (max-width: 1200px) {
    .column-header:nth-child(n+16) {
        display: none;
    }
}
@media (max-width: 1000px) {
    .column-header:nth-child(n+13) {
        display: none;
    }
}
@media (max-width: 800px) {
    .column-header:nth-child(n+10) {
        display: none;
    }
}
@media (max-width: 600px) {
    .column-header:nth-child(n+8) {
        display: none;
    }
}

/* 워크시트 본문 */
.worksheet-body {
    flex: 1;
    overflow: auto;
    position: relative;
    min-height: 0; /* flexbox 스크롤 가능하도록 */
    max-height: calc(100vh - 200px); /* 리본 및 상태바 제외한 높이 */
}

.worksheet-row {
    display: flex;
    height: 20px;
    border-bottom: 1px solid #e1e1e1;
}

.row-header {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    background: #f3f2f1;
    border-right: 1px solid #d1d1d1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #323130;
    cursor: pointer;
    flex-shrink: 0;
}

.cell {
    width: 80px;
    min-width: 80px;
    height: 20px;
    border-right: 1px solid #e1e1e1;
    border-bottom: 1px solid #e1e1e1;
    padding: 0 4px;
    display: flex;
    align-items: center;
    font-size: 11px;
    font-family: '맑은 고딕', sans-serif;
    cursor: cell;
    background: white;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
    position: relative;
}

/* 선택된 셀 스타일 */
.cell.selected {
    outline: 2px solid #217346;
    outline-offset: -1px;
    background: white;
    z-index: 10;
}

/* 반응형 셀 - 헤더와 정확히 맞춤 */
@media (max-width: 1400px) {
    .cell:nth-child(n+19) {
        display: none;
    }
}
@media (max-width: 1200px) {
    .cell:nth-child(n+16) {
        display: none;
    }
}
@media (max-width: 1000px) {
    .cell:nth-child(n+13) {
        display: none;
    }
}
@media (max-width: 800px) {
    .cell:nth-child(n+10) {
        display: none;
    }
}
@media (max-width: 600px) {
    .cell:nth-child(n+8) {
        display: none;
    }
}

/* 데이터 타입별 스타일 */
.cell.number {
    text-align: right;
    font-family: 'Consolas', monospace;
}

.cell.header {
    background: #d6dce4;
    font-weight: 600;
    text-align: center;
}

.cell.stock-name {
    color: #0066cc;
}

.cell.price {
    text-align: right;
    font-family: 'Consolas', monospace;
}

.cell.rate-positive {
    color: #c00000;
    text-align: right;
    font-family: 'Consolas', monospace;
}

.cell.rate-negative {
    color: #0070c0;
    text-align: right;
    font-family: 'Consolas', monospace;
}

.cell.theme-name {
    background: #e7f3ff;
    font-weight: 600;
    color: #0066cc;
    text-align: center;
}

/* 상태 표시줄 */
.status-bar {
    height: 24px;
    background: #f3f2f1;
    border-top: 1px solid #d1d1d1;
    display: flex;
    align-items: center;
    font-size: 11px;
    padding: 0 8px;
}

.sheet-tabs {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 1px;
}

.sheet-tab {
    padding: 2px 12px;
    background: white;
    border: 1px solid #d1d1d1;
    border-bottom: none;
    cursor: pointer;
    font-size: 11px;
    white-space: nowrap;
}

.sheet-tab.active {
    background: white;
    border-top: 2px solid #217346;
    font-weight: 600;
}
