/* TubeTax YouTube Style - Dark Theme */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Roboto', 'Arial', sans-serif;
    background-color: #0f0f0f;
    color: #fff;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 100%;
    position: relative;
    overflow: hidden;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(20px);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 56px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo {
    flex-shrink: 0;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.header-icon-btn:active {
    background-color: rgba(255, 255, 255, 0.1);
}

.header-icon {
    width: 24px;
    height: 24px;
    fill: #fff;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-top: 56px;
    margin-bottom: 56px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Category Chips */
.category-chips {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    scrollbar-width: none;
    position: sticky;
    top: 0;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.category-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    background-color: rgba(255, 255, 255, 0.1);
    color: #f1f1f1;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip.active {
    background-color: #f1f1f1;
    color: #0f0f0f;
}

.chip:active {
    transform: scale(0.95);
}

/* Chart Feed */
.chart-feed {
    display: flex;
    flex-direction: column;
    padding-bottom: 20px;
}

/* Chart Card - YouTube Video Style */
.chart-card {
    margin-bottom: 16px;
    cursor: pointer;
    transition: opacity 0.2s;
    width: 100%;
    overflow: hidden; /* 내부 요소 넘침 방지 */
}

.chart-card:active {
    opacity: 0.8;
}

.chart-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 5/3;
    background-color: #1a1a1a;
    overflow: hidden;
}

.chart-thumbnail canvas {
    width: 100%;
    height: 100%;
}

.chart-type-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.chart-type-badge.expense {
    background-color: rgba(255, 82, 82, 0.9);
}

.chart-type-badge.income {
    background-color: rgba(76, 175, 80, 0.9);
}

.chart-category-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.chart-info {
    display: flex;
    padding: 12px 16px;
    gap: 12px;
}

.chart-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-icon svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.chart-icon.expense {
    background: linear-gradient(135deg, #ff5252 0%, #f48fb1 100%);
}

.chart-icon.income {
    background: linear-gradient(135deg, #4caf50 0%, #81c784 100%);
}

.chart-meta {
    flex: 1;
    min-width: 0;
}

.chart-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: #f1f1f1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.chart-subtitle {
    font-size: 12px;
    color: #aaa;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chart-more-btn {
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    flex-shrink: 0;
}

.chart-more-btn svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #aaa;
    gap: 16px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #ff0000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(20px);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    z-index: 100;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 0;
    height: 100%;
    transition: transform 0.15s ease;
}

.nav-item:active {
    transform: scale(0.92);
}

.nav-item .nav-icon {
    width: 24px;
    height: 24px;
    fill: #fff;
    opacity: 0.6;
}

.nav-item.active .nav-icon {
    opacity: 1;
}

.nav-item span {
    font-size: 10px;
    color: #fff;
    opacity: 0.6;
    font-weight: 500;
}

.nav-item.active span {
    opacity: 1;
}

/* Detail Overlay - 유튜브 스타일 페이지 전환 */
.detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    background-color: #0f0f0f;
    z-index: 200;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    overflow: hidden; /* 전체 넘침 방지 */
}

.detail-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.detail-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    height: 56px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    gap: 12px;
    flex: 0 0 auto; /* 내용 크기만큼, 줄어들지 않음 */
    overflow: hidden; /* 넘침 방지 */
}

.back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-btn .header-icon {
    fill: #fff;
}

.detail-title-text {
    flex: 1;
    font-size: 18px;
    font-weight: 500;
}

/* 고정: 메인 차트 영역 (5:3 비율) */
.detail-chart-fixed {
    width: 100%;
    aspect-ratio: 5/3;
    background-color: #1a1a1a;
    padding: 16px;
    flex: 0 0 auto; /* 내용 크기만큼, 줄어들지 않음 */
    overflow: hidden; /* 넘침 방지 */
}

.detail-chart-fixed canvas {
    width: 100%;
    height: 100%;
}

/* 스크롤 영역: 정보 + 관련 차트 */
.detail-scroll-area {
    flex: 1 1 auto; /* 나머지 높이 전부 차지 */
    overflow-y: auto; /* 세로 스크롤 */
    overflow-x: hidden; /* 가로 넘침 방지 */
    -webkit-overflow-scrolling: touch;
}

.detail-info {
    padding: 16px;
    background-color: #0f0f0f;
    overflow: hidden; /* 넘침 방지 */
}

.detail-chart-title {
    font-size: 18px;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 8px;
}

.detail-chart-subtitle {
    font-size: 14px;
    color: #aaa;
    line-height: 1.5;
    margin-bottom: 16px;
}

.detail-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #aaa;
}

.stat-item svg {
    width: 18px;
    height: 18px;
    fill: #aaa;
}

.detail-actions {
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 16px;
    color: #fff;
}

.action-btn:active {
    opacity: 0.7;
}

.action-btn svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

.action-btn span {
    font-size: 12px;
    font-weight: 500;
}

/* Related Charts - 메인 피드와 동일한 스타일 */
.related-section {
    padding: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden; /* 넘침 방지 */
}

.related-title {
    font-size: 16px;
    font-weight: 500;
    padding: 16px;
    padding-bottom: 8px;
}

.related-charts {
    display: flex;
    flex-direction: column;
    padding-bottom: 40px;
    overflow: hidden; /* 넘침 방지 */
}

/* 관련 차트 내 카드 - 넘침 방지 */
.related-charts .chart-card {
    width: 100%;
    overflow: hidden;
}

/* Data Panel - YouTube Comments Style */
.data-panel-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 299;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.data-panel-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.data-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #212121;
    border-radius: 16px 16px 0 0;
    z-index: 300;
    max-height: 70vh;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.data-panel.active {
    transform: translateY(0);
}

.data-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.data-panel-title {
    font-size: 16px;
    font-weight: 500;
}

.data-panel-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.data-panel-close .header-icon {
    fill: #fff;
}

.data-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
}

.data-table th {
    color: #aaa;
    font-weight: 500;
    position: sticky;
    top: 0;
    background-color: #212121;
}

.data-table td {
    color: #f1f1f1;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-value {
    font-weight: 500;
    font-family: 'Roboto Mono', monospace;
}

.data-value.positive {
    color: #4caf50;
}

.data-value.negative {
    color: #ff5252;
}

/* Desktop constraint */
@media (min-width: 481px) {
    .app-container {
        max-width: 420px;
        margin: 0 auto;
        border-left: 1px solid rgba(255, 255, 255, 0.1);
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }

    .header,
    .bottom-nav {
        max-width: 420px;
        left: 50%;
        transform: translateX(-50%);
    }

    /* Detail overlay - 데스크톱에서도 전체 화면으로 */
    .detail-overlay {
        max-width: 420px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        height: 100vh;
    }

    .detail-overlay.active {
        transform: translateX(-50%);
    }

    .data-panel {
        max-width: 420px;
        left: 50%;
        transform: translateX(-50%) translateY(100%);
    }

    .data-panel.active {
        transform: translateX(-50%) translateY(0);
    }
}

/* Scrollbar Hidden */
::-webkit-scrollbar {
    display: none;
}

* {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* Safe area */
@supports (padding: max(0px)) {
    .header {
        padding-top: max(8px, env(safe-area-inset-top));
        height: calc(56px + max(0px, env(safe-area-inset-top)));
    }

    .bottom-nav {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
        height: calc(56px + max(0px, env(safe-area-inset-bottom)));
    }

    .main-content {
        margin-top: calc(56px + max(0px, env(safe-area-inset-top)));
        margin-bottom: calc(56px + max(0px, env(safe-area-inset-bottom)));
    }
}

/* ========================================
   YouTube 스타일 중앙 플러스 버튼 (2024)
   ======================================== */
.create-btn {
    position: relative;
}

.create-btn-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.create-btn:active .create-btn-circle {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.2);
}

.create-icon {
    width: 24px;
    height: 24px;
    fill: #fff;
}

/* ========================================
   Flatfile 스타일 업로드 오버레이
   ======================================== */
.upload-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh; /* dynamic viewport height for mobile */
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f0f23 100%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    overflow: hidden;
}

.upload-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.upload-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    height: 56px;
    background: rgba(0, 0, 0, 0.3);
    gap: 16px;
}

/* 미니멀 헤더: X 버튼만 왼쪽에 배치 (작은 높이) */
.upload-header.upload-header-minimal {
    justify-content: flex-start;
    background: transparent;
    height: 44px;
    padding: 4px 12px;
}

.upload-title-text {
    font-size: 18px;
    font-weight: 500;
    color: #fff;
}

.upload-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8px 16px 20px;
    overflow: hidden; /* 넘침 방지 */
    min-height: 0; /* flex item 축소 허용 */
}

/* Step Indicator */
.upload-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    gap: 8px;
    flex-shrink: 0; /* 축소 방지 */
}

.upload-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    opacity: 0.4;
    transition: opacity 0.3s;
}

.upload-step.active {
    opacity: 1;
}

.upload-step.completed {
    opacity: 1;
}

.step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.2);
    border: 2px solid rgba(139, 92, 246, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #8B5CF6;
    transition: all 0.3s;
}

.upload-step.active .step-number {
    background: #8B5CF6;
    border-color: #8B5CF6;
    color: #fff;
}

.upload-step.completed .step-number {
    background: #10B981;
    border-color: #10B981;
    color: #fff;
}

.upload-step span {
    font-size: 12px;
    color: #aaa;
}

.upload-step.active span {
    color: #fff;
}

.step-line {
    width: 40px;
    height: 2px;
    background: rgba(139, 92, 246, 0.3);
    margin-bottom: 20px;
}

/* Upload Zone (Flatfile 스타일) */
.upload-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed rgba(139, 92, 246, 0.5);
    border-radius: 16px;
    padding: 24px 16px;
    text-align: center;
    background: rgba(139, 92, 246, 0.05);
    transition: all 0.3s ease;
    cursor: pointer;
    min-height: 0; /* 화면에 맞게 축소 허용 */
}

.upload-zone:hover {
    border-color: #8B5CF6;
    background: rgba(139, 92, 246, 0.1);
}

.upload-zone.drag-over {
    border-color: #A78BFA;
    border-width: 3px;
    background: rgba(139, 92, 246, 0.25);
    transform: scale(1.02);
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.4);
}

.upload-zone-icon {
    margin-bottom: 12px;
    animation: float 3s ease-in-out infinite;
}

.upload-zone-icon svg {
    width: 48px;
    height: 48px;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.upload-zone-title {
    font-size: 16px;
    font-weight: 500;
    color: #fff;
    margin-bottom: 6px;
}

.upload-zone-subtitle {
    font-size: 13px;
    color: #888;
    margin-bottom: 16px;
}

.upload-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #8B5CF6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-btn:hover {
    background: #7C3AED;
    transform: translateY(-2px);
}

.upload-btn:active {
    transform: translateY(0);
}

/* Upload Progress */
.upload-progress {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 24px;
}

.progress-icon {
    margin-bottom: 24px;
}

.progress-spinner {
    width: 64px;
    height: 64px;
    border: 4px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8B5CF6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.progress-title {
    font-size: 20px;
    font-weight: 500;
    color: #fff;
    margin-bottom: 8px;
}

.progress-subtitle {
    font-size: 14px;
    color: #888;
    margin-bottom: 24px;
}

.progress-bar {
    width: 100%;
    max-width: 300px;
    height: 6px;
    background: rgba(139, 92, 246, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8B5CF6, #EC4899);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

/* Upload Success */
.upload-success {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 24px;
}

.success-icon {
    margin-bottom: 24px;
    animation: pop 0.4s ease;
}

@keyframes pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.success-title {
    font-size: 24px;
    font-weight: 600;
    color: #10B981;
    margin-bottom: 8px;
}

.success-subtitle {
    font-size: 14px;
    color: #888;
    margin-bottom: 24px;
}

.success-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 32px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 24px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.stat-box-value {
    font-size: 28px;
    font-weight: 700;
    color: #10B981;
}

.stat-box-label {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.success-btn {
    padding: 14px 32px;
    background: #10B981;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.success-btn:hover {
    background: #059669;
}

/* Upload Error */
.upload-error {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 24px;
}

.error-icon {
    margin-bottom: 24px;
}

.error-title {
    font-size: 24px;
    font-weight: 600;
    color: #EF4444;
    margin-bottom: 8px;
}

.error-subtitle {
    font-size: 14px;
    color: #888;
    margin-bottom: 24px;
    max-width: 300px;
}

.error-btn {
    padding: 14px 32px;
    background: transparent;
    color: #EF4444;
    border: 2px solid #EF4444;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.error-btn:hover {
    background: #EF4444;
    color: #fff;
}

/* YouTube 스타일 스켈레톤 로딩 */
.skeleton-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    overflow-y: auto;
}

.skeleton-loading-text {
    text-align: center;
    color: #888;
    font-size: 14px;
    margin-bottom: 20px;
}

.skeleton-cards {
    display: flex;
    flex-direction: column;
}

.skeleton-card {
    margin-bottom: 16px;
}

.skeleton-thumbnail {
    width: 100%;
    aspect-ratio: 5/3;
    border-radius: 12px;
    background: #2a2a2a;
}

.skeleton-info {
    display: flex;
    padding: 12px 0;
    gap: 12px;
}

.skeleton-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #2a2a2a;
    flex-shrink: 0;
}

.skeleton-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-title {
    height: 16px;
    width: 85%;
    border-radius: 4px;
    background: #2a2a2a;
}

.skeleton-subtitle {
    height: 12px;
    width: 60%;
    border-radius: 4px;
    background: #2a2a2a;
}

/* Shimmer 애니메이션 */
.skeleton-shimmer {
    background: linear-gradient(
        90deg,
        #2a2a2a 0%,
        #3a3a3a 50%,
        #2a2a2a 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Desktop constraint for upload overlay */
@media (min-width: 481px) {
    .upload-overlay {
        max-width: 420px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        height: 100%;
        height: 100dvh;
    }
}

/* ========================================
   마이페이지 / 로그인 (Google/YouTube 스타일)
   ======================================== */
.mypage-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background-color: #0f0f0f;
    z-index: 300;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.mypage-overlay.active {
    display: flex;
}

/* 게스트 컨테이너 (로그아웃 상태) */
.guest-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0f0f0f;
}

.guest-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.guest-content .profile-avatar {
    width: 100px;
    height: 100px;
    margin-bottom: 24px;
    background: #282828;
}

.guest-content .profile-avatar.guest {
    background: #3d3d3d;
}

.guest-message {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 24px;
    text-align: center;
}

.login-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    color: #3ea6ff;
    background: transparent;
    border: 1px solid #3ea6ff;
    border-radius: 18px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.login-btn:hover {
    background: rgba(62, 166, 255, 0.1);
}

.login-btn svg {
    fill: #3ea6ff;
}

/* Google 로그인 버튼 */
.google-login-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background: #4285F4;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.google-login-btn:hover {
    background: #3367D6;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.google-login-btn svg {
    background: #fff;
    border-radius: 2px;
    padding: 2px;
}

/* Large Google Login Button (Login Page) - Modern Style */
.google-login-btn-large {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    padding: 12px 24px 12px 56px !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    color: #1f1f1f !important;
    background: #ffffff !important;
    border: 1px solid #dadce0 !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s !important;
    box-shadow: none !important;
    max-width: 400px !important;
    width: calc(100% - 48px) !important;
    margin: 0 auto !important;
    margin-top: -80px !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif !important;
    letter-spacing: 0.25px !important;
    z-index: 100 !important;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1) !important;
    touch-action: manipulation !important;
}

.google-login-btn-large:hover {
    background: #f7f8f8 !important;
    border-color: #c6c6c6 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important;
}

.google-login-btn-large:active {
    background: #f1f1f1 !important;
}

.google-login-btn-large svg {
    position: absolute !important;
    left: 16px !important;
    flex-shrink: 0 !important;
    width: 20px !important;
    height: 20px !important;
    pointer-events: none !important;
}

.google-login-btn-large span {
    pointer-events: none !important;
}

/* 프로필 이미지 */
.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* 로그인 컨테이너 */
.auth-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
}

/* 닫기 버튼 */
.auth-close-btn {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #aaa;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.auth-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: #212121;
    border-radius: 16px;
    padding: 40px 32px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.auth-logo {
    margin-bottom: 24px;
}

.auth-title {
    font-size: 24px;
    font-weight: 400;
    color: #fff;
    margin-bottom: 8px;
}

.auth-subtitle {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 32px;
}

/* Google 스타일 입력 필드 */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    position: relative;
}

.auth-input {
    width: 100%;
    padding: 16px 14px;
    font-size: 16px;
    color: #fff;
    background: transparent;
    border: 1px solid #5f6368;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-input:focus {
    border-color: #8ab4f8;
    box-shadow: 0 0 0 1px #8ab4f8;
}

.auth-input:focus + .auth-label,
.auth-input:not(:placeholder-shown) + .auth-label {
    top: -8px;
    left: 10px;
    font-size: 12px;
    color: #8ab4f8;
    background: #212121;
    padding: 0 4px;
}

.auth-label {
    position: absolute;
    top: 16px;
    left: 14px;
    font-size: 16px;
    color: #aaa;
    pointer-events: none;
    transition: all 0.2s ease;
}

.auth-error {
    color: #f28b82;
    font-size: 13px;
    text-align: left;
    min-height: 20px;
}

.auth-btn {
    width: 100%;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-btn.primary {
    background: #8ab4f8;
    color: #202124;
}

.auth-btn.primary:hover {
    background: #aecbfa;
}

.auth-btn.primary:active {
    background: #78a9f7;
}

.auth-btn.primary:disabled {
    background: #5f6368;
    color: #9aa0a6;
    cursor: not-allowed;
}

.auth-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 13px;
    color: #9aa0a6;
}

.auth-hint {
    display: block;
    color: #9aa0a6;
}

/* 프로필 컨테이너 */
.profile-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.profile-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    height: 56px;
}

.profile-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px;
    overflow-y: auto;
}

.profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.avatar-icon {
    width: 64px;
    height: 64px;
    fill: #fff;
}

.profile-name {
    font-size: 20px;
    font-weight: 500;
    color: #fff;
    margin-bottom: 4px;
}

.profile-email {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 24px;
}

.profile-stats {
    display: flex;
    gap: 32px;
    padding: 20px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 24px;
    width: 100%;
    justify-content: center;
}

.profile-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.profile-stat .stat-value {
    font-size: 20px;
    font-weight: 500;
    color: #fff;
}

.profile-stat .stat-label {
    font-size: 12px;
    color: #aaa;
}

.profile-menu {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 14px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    color: #fff;
    font-size: 15px;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.menu-item svg {
    width: 24px;
    height: 24px;
    fill: #aaa;
}

.menu-item.logout {
    color: #f28b82;
}

.menu-item.logout svg {
    fill: #f28b82;
}

/* Desktop constraint for mypage overlay */
@media (min-width: 481px) {
    .mypage-overlay {
        max-width: 420px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        height: 100%;
        height: 100dvh;
    }
}

/* ========================================
   월 선택기 (YouTube Music 스타일)
   ======================================== */
.month-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(15, 15, 15, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.month-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.month-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.month-nav-btn:active {
    transform: scale(0.95);
}

.month-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.month-nav-btn svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.month-display {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
    min-width: 160px;
    justify-content: center;
}

.month-display:hover {
    background: rgba(255, 255, 255, 0.15);
}

.month-text {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
}

.dropdown-icon {
    width: 18px;
    height: 18px;
    fill: #aaa;
    transition: transform 0.2s;
}

.month-display.open .dropdown-icon {
    transform: rotate(180deg);
}

/* ========================================
   KPI 카드 (Shopify/Stripe 스타일)
   ======================================== */
.kpi-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(180deg, rgba(15, 15, 15, 0.95) 0%, transparent 100%);
}

.kpi-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s ease;
}

.kpi-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}

.kpi-card.highlight {
    background: linear-gradient(135deg, rgba(99, 91, 255, 0.15) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-color: rgba(139, 92, 246, 0.3);
}

.kpi-label {
    font-size: 11px;
    font-weight: 500;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    font-family: 'Roboto', sans-serif;
    letter-spacing: -0.5px;
}

.kpi-value.income {
    color: #4caf50;
}

.kpi-value.expense {
    color: #ff5252;
}

.kpi-value.positive {
    color: #4caf50;
}

.kpi-value.negative {
    color: #ff5252;
}

.kpi-change {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
}

.kpi-change svg {
    width: 14px;
    height: 14px;
}

.kpi-change.positive {
    color: #4caf50;
}

.kpi-change.positive svg {
    fill: #4caf50;
}

.kpi-change.negative {
    color: #ff5252;
}

.kpi-change.negative svg {
    fill: #ff5252;
}

.kpi-change.neutral {
    color: #888;
}

.kpi-change.neutral svg {
    fill: #888;
}

.kpi-subtitle {
    font-size: 11px;
    color: #666;
}

/* KPI 카드 스켈레톤 로딩 */
.kpi-card.loading .kpi-value,
.kpi-card.loading .kpi-change,
.kpi-card.loading .kpi-subtitle {
    background: linear-gradient(90deg, #2a2a2a 0%, #3a3a3a 50%, #2a2a2a 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
    color: transparent;
}

/* ========================================
   히트맵 차트 스타일
   ======================================== */
.heatmap-container {
    padding: 12px;
    background: #1a1a1a;
    border-radius: 8px;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: 40px repeat(7, 1fr);
    gap: 2px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    transition: transform 0.2s;
}

.heatmap-cell:hover {
    transform: scale(1.1);
    z-index: 1;
}

.heatmap-cell.label {
    background: transparent;
    font-weight: 500;
    color: #888;
}

.heatmap-cell.level-0 { background: rgba(255, 82, 82, 0.1); }
.heatmap-cell.level-1 { background: rgba(255, 82, 82, 0.25); }
.heatmap-cell.level-2 { background: rgba(255, 82, 82, 0.4); }
.heatmap-cell.level-3 { background: rgba(255, 82, 82, 0.6); }
.heatmap-cell.level-4 { background: rgba(255, 82, 82, 0.8); }
.heatmap-cell.level-5 { background: rgba(255, 82, 82, 1); }

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
    font-size: 11px;
    color: #888;
}

.heatmap-legend-scale {
    display: flex;
    gap: 2px;
}

.heatmap-legend-scale .heatmap-cell {
    width: 12px;
    height: 12px;
}
