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

.sales-v2-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.sales-v2-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 50%, #f9fafb 100%);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
    margin-left: var(--sidebar-width, 360px);
    transition: margin-left 0.3s ease;
    /* Align numeric text for better scanability */
    font-variant-numeric: tabular-nums;
}

@media (max-width: 1023px) {
    .sales-v2-main {
        margin-left: 0;
    }
}

/* ヘッダー */
.sales-v2-main .header {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(229, 231, 235, 1);
    /* 追従をやめてページTOPにのみ表示（スクロールで固定しない） */
    position: relative;
    top: auto;
    z-index: 1;
    padding: 16px 24px;
}

.sales-v2-main .header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.sales-v2-main .menu-toggle {
    display: none;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 18px;
    color: #4b5563;
    transition: all 0.2s ease;
}

.sales-v2-main .menu-toggle:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: #ffffff;
    border-color: rgba(99, 102, 241, 0.65);
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.24);
}

@media (max-width: 1023px) {
    .sales-v2-main .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

.sales-v2-main .header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sales-v2-main .header-branding {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sales-v2-main .logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sales-v2-main .page-title {
    font-size: 24px;
    font-weight: bold;
    background: linear-gradient(135deg, #111827 0%, #4b5563 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sales-v2-main .page-subtitle {
    font-size: 14px;
    color: #6b7280;
    margin-top: 2px;
}

/* コントロールバー */
.sales-v2-main .control-bar {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.sales-v2-main .control-bar-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: center;
}

.sales-v2-main .control-bar select,
.sales-v2-main .control-bar button {
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    min-height: 38px;
    line-height: 1.2;
}

.sales-v2-main .control-bar select {
    background: white;
    border: 1px solid #e5e7eb;
    color: #374151;
    cursor: pointer;
    min-width: 110px;
}

.sales-v2-main .control-bar select:hover {
    border-color: #d1d5db;
}

.sales-v2-main .control-bar select:focus {
    outline: none;
    ring: 2px;
    ring-color: #4f46e5;
    border-color: transparent;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.sales-v2-main .btn-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    color: white;
    border: none;
    cursor: pointer;
}

.sales-v2-main .btn-primary:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.sales-v2-main .btn-success {
    background: linear-gradient(135deg, #059669 0%, #0d9488 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

@media (min-width: 1024px) {
    .sales-v2-main .btn-success {
        margin-left: auto;
    }
}

.sales-v2-main .btn-success:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* メインラッパー */
.sales-v2-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* メインエリア */
.sales-v2-main .main-area {
    flex: 1;
    padding: 24px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}
@media (min-width: 1280px) and (max-width: 1919px) {
    .sales-v2-main .main-area { padding-right: 32px; }
}

/* サマリーセクション */
.sales-v2-main .summary-section {
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid rgba(229, 231, 235, 0.5);
}

.sales-v2-main .summary-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background 0.3s;
}

.sales-v2-main .summary-header:hover {
    background: rgba(249, 250, 251, 0.5);
}

.sales-v2-main .summary-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sales-v2-main .summary-icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sales-v2-main .summary-icon-wrapper.purple {
    background: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
}

.sales-v2-main .summary-icon-wrapper.green {
    background: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
}

.sales-v2-main .summary-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.sales-v2-main .summary-badge {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 9999px;
    font-weight: 500;
}

.sales-v2-main .summary-badge.purple {
    background: #e0e7ff;
    color: #4338ca;
}

.sales-v2-main .summary-badge.green {
    background: #bbf7d0;
    color: #047857;
}

.sales-v2-main .summary-chevron {
    transition: transform 0.3s;
}

.sales-v2-main .summary-content {
    padding: 0 24px 24px;
    display: none;
    animation: slideIn 0.3s ease-in-out;
}

.sales-v2-main .summary-content.open {
    display: block;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 統計カード */
.sales-v2-main .stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

/* Grid children should shrink within tracks to keep equal width */
.sales-v2-main .stat-grid > .stat-card {
    min-width: 0;
    width: 100%;
}

/* デスクトップ (1920px以上) */
@media (min-width: 1920px) {
    .sales-v2-main .stat-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 24px;
    }
}

/* ノートPC (1280px - 1919px) */
@media (min-width: 1280px) and (max-width: 1919px) {
    .sales-v2-main .stat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 20px;
    }
}

/* タブレット横向き (1024px - 1279px) */
@media (min-width: 1024px) and (max-width: 1279px) {
    .sales-v2-main .stat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 18px;
    }
}

/* タブレット縦向き (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .sales-v2-main .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }
}

/* モバイル (767px以下) */
@media (max-width: 767px) {
    .sales-v2-main .stat-grid {
        grid-template-columns: repeat(1, 1fr);
        gap: 12px;
    }
}

.sales-v2-main .stat-card {
    position: relative;
    animation: fadeInUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sales-v2-main .stat-card-glow {
    position: absolute;
    inset: -2px;
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.4s;
    z-index: -1;
}

.sales-v2-main .stat-card:hover .stat-card-glow {
    opacity: 1;
}

.sales-v2-main .stat-card-content {
    position: relative;
    background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
    border-radius: 20px;
    padding: 24px 96px 24px 24px; /* 右側にアイコン用の余白を広めに確保 */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(229, 231, 235, 0.3);
    overflow: hidden;
}

/* アイコンを表示しないカードは右側の余白を通常化 */
.sales-v2-main .stat-card-content.no-icon {
    padding-right: 24px;
}

.sales-v2-main .stat-card:hover .stat-card-content {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: rgba(229, 231, 235, 0.1);
}

.sales-v2-main .stat-card-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    opacity: 0.8;
}

.sales-v2-main .stat-card-header {
    display: grid;
    grid-template-columns: 1fr; /* アイコンは絶対配置のためレイアウトから除外 */
    align-items: center;
    row-gap: 8px;
    margin-bottom: 16px;
}

.sales-v2-main .stat-card-info {
    min-width: 0; /* テキストあふれ防止 */
    display: grid;
    grid-template-rows: 20px 1fr 24px; /* ラベル固定20px、値は可変、バッジ固定24px */
    row-gap: 8px;
}

.sales-v2-main .stat-card-label {
    font-size: 14px;
    font-weight: 600;
    color: #4b5563; /* コントラスト強化 */
    letter-spacing: 0.02em;
    line-height: 1.2;
    min-height: 18px; /* 行高さを揃える */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sales-v2-main .stat-card-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 32px; /* ベースラインそろえ */
    align-self: center; /* 可変領域の中央寄せで安定 */
}

@media (max-width: 640px) {
    .sales-v2-main .stat-card-value {
        font-size: 24px;
    }
}

/* Larger values on wide desktop for readability */
@media (min-width: 1920px) {
    .sales-v2-main .stat-card-value {
        font-size: 32px;
    }
}

.sales-v2-main .stat-card-change {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    gap: 4px;
    min-height: 22px; /* 背景カプセルの高さを統一 */
}

.sales-v2-main .stat-card-change.positive {
    background: #ecfdf5; /* 明度を上げて文字とのコントラストを確保 */
    color: #047857;      /* より濃い緑 */
}

.sales-v2-main .stat-card-change.negative {
    background: #fee2e2; /* 明度を上げて文字とのコントラストを確保 */
    color: #b91c1c;      /* より濃い赤 */
}

.sales-v2-main .stat-card-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute; /* 数値と重ならないよう固定配置 */
    right: 16px;
    top: 16px;
    overflow: hidden;
    pointer-events: none;
}

.sales-v2-main .stat-card-icon-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.3) 0%, transparent 100%);
}

.sales-v2-main .stat-card-icon {
    width: 26px;
    height: 26px;
    aspect-ratio: 1 / 1;
    z-index: 1;
    position: relative;
}

@media (min-width: 1440px) {
    .sales-v2-main .stat-card-icon {
        width: 28px;
        height: 28px;
        aspect-ratio: 1 / 1;
    }
}

@media (min-width: 1920px) {
    .sales-v2-main .stat-card-icon {
        width: 32px;
        height: 32px;
        aspect-ratio: 1 / 1;
    }
}

/* Equalize card height per breakpoint for visual rhythm */
@media (min-width: 1920px) {
    .sales-v2-main .stat-card-content { min-height: 176px; }
}
@media (min-width: 1280px) and (max-width: 1919px) {
    .sales-v2-main .stat-card-content { min-height: 164px; }
}
@media (min-width: 1024px) and (max-width: 1279px) {
    .sales-v2-main .stat-card-content { min-height: 152px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
    .sales-v2-main .stat-card-content { min-height: 144px; }
}

/* テーブルグリッド */
.sales-v2-main .table-grid {
    display: grid;
    gap: 24px;
}

/* デスクトップ (1920px以上) */
@media (min-width: 1920px) {
    .sales-v2-main .table-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 24px;
    }
}

/* ノートPC (1280px - 1919px) */
@media (min-width: 1280px) and (max-width: 1919px) {
    .sales-v2-main .table-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

/* タブレット横向き (1024px - 1279px) */
@media (min-width: 1024px) and (max-width: 1279px) {
    .sales-v2-main .table-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
    }
}

/* タブレット縦向き (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .sales-v2-main .table-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .sales-v2-main .sales-table-container {
        min-height: 400px;
    }
}

/* モバイル (767px以下) */
@media (max-width: 767px) {
    .sales-v2-main .table-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* 売上テーブル */
.sales-v2-main .sales-table-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    overflow: hidden;
    height: 100%;
    min-height: 500px;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(229, 231, 235, 0.5);
    transition: all 0.3s;
}

.sales-v2-main .sales-table-container:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.sales-v2-main .sales-table-header {
    padding: 16px;
    color: white;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sales-v2-main .sales-table-header.purple {
    background: linear-gradient(135deg, #a855f7 0%, #a855f7 100%);
}

.sales-v2-main .sales-table-header.blue {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
}

.sales-v2-main .sales-table-header.green {
    background: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
}

.sales-v2-main .sales-table-header.orange {
    background: linear-gradient(135deg, #f97316 0%, #ef4444 100%);
}

.sales-v2-main .table-wrapper {
    overflow: auto;
    flex: 1;
    padding: 0 10px 8px;
}
@media (min-width: 1920px) {
    .sales-v2-main .table-wrapper { padding: 0 12px 10px; }
}

.sales-v2-main .sales-table {
    width: 100%;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.sales-v2-main .sales-table thead {
    background: rgba(255, 255, 255, 0.9);
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    backdrop-filter: blur(10px);
}

.sales-v2-main .sales-table th {
    padding: 12px;
    text-align: left;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
}

.sales-v2-main .sales-table th:not(:first-child) {
    text-align: right;
}

.sales-v2-main .sales-table tbody tr {
    border-bottom: 1px solid rgba(243, 244, 246, 1);
    transition: background 0.2s;
}

/* ゼブラストライプで可読性を向上 */
.sales-v2-main .sales-table tbody tr:nth-child(even) {
    background: rgba(249, 250, 251, 0.35);
}

.sales-v2-main .sales-table tbody tr:hover {
    background: rgba(249, 250, 251, 0.5);
}

.sales-v2-main .sales-table tbody tr.total-row {
    font-weight: 600;
    border-bottom: 2px solid #e5e7eb;
}

.sales-v2-main .sales-table tbody tr.total-row.purple {
    background: #faf5ff;
}

.sales-v2-main .sales-table tbody tr.total-row.blue {
    background: #eff6ff;
}

.sales-v2-main .sales-table tbody tr.total-row.green {
    background: #ecfdf5;
}

.sales-v2-main .sales-table tbody tr.total-row.orange {
    background: #fff7ed;
}

.sales-v2-main .sales-table td {
    padding: 8px 12px;
    color: #374151;
    line-height: 1.4;
}

.sales-v2-main .sales-table td:not(:first-child) {
    text-align: right;
    white-space: nowrap;
}

.sales-v2-main .sales-table .sub-text {
    display: block;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 2px;
}

@media (max-width: 640px) {
    .sales-v2-main .sales-table .sub-text {
        display: none;
    }
}

.sales-v2-main .sales-table tbody tr:not(.total-row) td:last-child {
    font-weight: 500;
}

/* フッター */
.sales-v2-main .footer {
    margin: 48px 0 24px;
    padding: 32px 0;
    text-align: center;
}

.sales-v2-main .footer-text {
    font-size: 12px;
    color: #9ca3af;
    font-weight: 500;
    letter-spacing: 0.05em;
}

/* アイコン（簡易SVG） */
.sales-v2-main .icon {
    width: 20px;
    height: 20px;
    display: inline-block;
    vertical-align: middle;
}

.sales-v2-main .icon-white {
    filter: brightness(0) invert(1);
}

/* レスポンシブ調整 - より詳細な設定 */

/* デスクトップ (1920px以上) */
@media (min-width: 1920px) {
    .header-content,
    .control-bar-inner,
    .sales-v2-main .main-area {
        max-width: 1800px;
    }
    
    .page-title {
        font-size: 28px;
    }
    
    .sales-v2-main .stat-card-value {
        font-size: 32px;
    }
}

/* ノートPC (1280px - 1919px) */
@media (min-width: 1280px) and (max-width: 1919px) {
    .header-content,
    .control-bar-inner,
    .sales-v2-main .main-area {
        max-width: 1200px;
    }
    
    .page-title {
        font-size: 24px;
    }
    
    .sales-v2-main .stat-card-value {
        font-size: 28px;
    }
    
    .sales-v2-main .sales-table {
        font-size: 14px;
    }
    .sales-v2-main .control-bar-inner { gap: 10px 14px; }
}

/* タブレット横向き (1024px - 1279px) */
@media (min-width: 1024px) and (max-width: 1279px) {
    .header-content,
    .control-bar-inner,
    .sales-v2-main .main-area {
        max-width: 960px;
        padding-left: 20px;
        padding-right: 20px;
    }
    
    .header {
        padding: 14px 20px;
    }
    
    .page-title {
        font-size: 22px;
    }
    
    .page-subtitle {
        font-size: 13px;
    }
    
    .sales-v2-main .stat-card-value {
        font-size: 26px;
    }
    
    .sales-v2-main .stat-card-content {
        padding: 20px;
    }
    .sales-v2-main .control-bar-inner { gap: 10px 12px; }
    
    .sales-v2-main .sales-table {
        font-size: 13px;
    }
    
    .sales-v2-main .sales-table th,
    .sales-v2-main .sales-table td {
        padding: 10px;
    }
}

/* タブレット縦向き (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .header-content,
    .control-bar-inner,
    .sales-v2-main .main-area {
        max-width: 720px;
        padding-left: 16px;
        padding-right: 16px;
    }
    
    .header {
        padding: 12px 16px;
    }
    
    .header-branding {
        gap: 10px;
    }
    
    .logo-icon {
        width: 32px;
        height: 32px;
    }
    
    .page-title {
        font-size: 20px;
    }
    
    .page-subtitle {
        font-size: 12px;
    }
    
    .control-bar {
        padding: 10px 16px;
    }
    
    .control-bar select,
    .control-bar button {
        padding: 7px 14px;
        font-size: 13px;
    }
    
    .btn-success {
        margin-left: 0;
        margin-top: 8px;
        width: 100%;
        justify-content: center;
    }
    
    .sales-v2-main .summary-title {
        font-size: 16px;
    }
    
    .sales-v2-main .stat-card-value {
        font-size: 24px;
    }
    
    .sales-v2-main .stat-card-content {
        padding: 18px;
    }
    
    .sales-v2-main .stat-card-label {
        font-size: 12px;
    }
    
    .sales-v2-main .sales-table {
        font-size: 12px;
    }
    
    .sales-v2-main .sales-table th,
    .sales-v2-main .sales-table td {
        padding: 8px;
    }
    
    .sales-v2-main .sales-table-container {
        min-height: 450px;
    }
}

/* モバイル (767px以下) */
@media (max-width: 767px) {
    .sales-v2-main .main-area {
        padding: 12px;
    }

    .sales-v2-main .sales-table-container {
        min-height: 400px;
    }

    .sales-v2-main .page-title {
        font-size: 18px;
    }

    .sales-v2-main .control-bar {
        padding: 12px;
    }
    
    .sales-v2-main .control-bar-inner {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sales-v2-main .control-bar select,
    .sales-v2-main .control-bar button {
        width: 100%;
    }

    .sales-v2-main .header {
        padding: 12px;
    }

    .sales-v2-main .header-branding {
        flex-direction: column;
        align-items: flex-start;
    }

    .sales-v2-main .logo-icon {
        width: 30px;
        height: 30px;
    }
    
    .sales-v2-main .stat-card-value {
        font-size: 22px;
    }
    
    .sales-v2-main .sales-table .sub-text {
        display: none;
    }
}

/* Focus-visible rings for keyboard users */
.sales-v2-main .btn-primary:focus-visible,
.sales-v2-main .btn-success:focus-visible,
.sales-v2-main .menu-toggle:focus-visible,
.sales-v2-main .control-bar select:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Motion safety for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .sales-v2-main .stat-card,
    .sales-v2-main .stat-card-content,
    .sales-v2-main .summary-content {
        animation: none !important;
        transition: none !important;
    }
}
