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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

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

h1 {
    color: #333;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.1rem;
}

.controls {
    margin-bottom: 30px;
}

.media-selector {
    display: flex;
    align-items: center;
    gap: 15px;
}

.media-selector label {
    font-weight: 600;
    color: #333;
}

.media-selector select {
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.media-selector select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    border: 2px solid #e9ecef;
    margin-bottom: 30px;
}

.filter-controls {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.filter-group select,
.filter-group input {
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
}

.filter-group input[type="text"] {
    min-width: 200px;
}

.summary-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 20px;
    border-top: 1px solid #dee2e6;
}

.media-counts {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.count-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.total-count {
    font-weight: 600;
    color: #333;
}

.input-section {
    margin-bottom: 30px;
}

.text-input-area h3 {
    margin-bottom: 20px;
    color: #333;
}

.text-input-area {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    border: 2px solid #e9ecef;
}

.upload-area, .text-input-area {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    border: 2px solid #e9ecef;
}

.upload-area h3, .text-input-area h3 {
    margin-bottom: 20px;
    color: #333;
}

.drop-zone {
    border: 3px dashed #dee2e6;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    transition: all 0.3s ease;
    background: white;
}

.drop-zone:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.drop-zone.dragover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.drop-zone p {
    margin: 10px 0;
    color: #666;
}

textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    resize: vertical;
    transition: all 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-secondary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.4);
}

.btn-secondary:active {
    transform: translateY(-1px);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.management-section {
    margin-bottom: 30px;
}

.add-form {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    border: 2px solid #e9ecef;
}

.add-form h4 {
    margin-bottom: 15px;
    color: #333;
}

.add-form-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.add-form-row input,
.add-form-row select {
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
}

.add-form-row input[type="date"] {
    min-width: 150px;
}

.add-form-row input[type="text"] {
    flex: 1;
    min-width: 120px;
}

#add-customer {
    min-width: 180px;
}

.add-form-row select {
    min-width: 120px;
}

.error-message {
    color: #dc3545;
    font-size: 14px;
    margin-top: 10px;
}

.grouped-view {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.group-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.group-header {
    color: #333;
    font-size: 1.3rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
}

.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
    font-size: 14px;
    line-height: 1.4;
}

.data-table th:nth-child(1),
.data-table td:nth-child(1) {
    width: 100px;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
    width: 200px;
}

.data-table th:nth-child(3),
.data-table td:nth-child(3) {
    width: 180px;
}

.data-table th:nth-child(4),
.data-table td:nth-child(4) {
    width: 220px;
}

.data-table th:nth-child(5),
.data-table td:nth-child(5) {
    width: 140px;
}

.data-table th:nth-child(6),
.data-table td:nth-child(6) {
    width: 120px;
}

.data-table th:nth-child(7),
.data-table td:nth-child(7) {
    width: 70px;
    text-align: center;
}

.data-table th:nth-child(8),
.data-table td:nth-child(8) {
    width: 80px;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.data-table tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

.editable {
    cursor: pointer;
    transition: background-color 0.2s;
}

.editable input {
    width: 100%;
    padding: 6px;
    border: 2px solid #667eea;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}

.editable:hover {
    background-color: rgba(102, 126, 234, 0.1);
}

.editing {
    background-color: rgba(102, 126, 234, 0.2);
}

.source-badge {
    padding: 2px 6px !important;
    border-radius: 10px !important;
    font-size: 10px !important;
    font-weight: 600 !important;
}

.media-suumo {
    background-color: rgba(34, 170, 85, 0.08);
}

.media-athome {
    background-color: rgba(221, 51, 51, 0.08);
}

.media-holmes {
    background-color: rgba(255, 136, 0, 0.1);
}

.media-jishahp {
    background-color: rgba(51, 102, 204, 0.08);
}

.media-nagatsuta {
    background-color: rgba(136, 68, 204, 0.08);
}

.media-aobadai {
    background-color: rgba(204, 68, 136, 0.08);
}

.media-sonota {
    background-color: rgba(153, 153, 153, 0.08);
}

.media-ur {
    background-color: rgba(0, 139, 139, 0.08);
}

.media-wakabadai {
    background-color: rgba(139, 90, 43, 0.08);
}

.media-tenpo {
    background-color: rgba(68, 68, 68, 0.08);
}

.media-nagatsuta .stat-badge,
.stat-badge.media-nagatsuta {
    background: #f3e9fb;
    border: 1px solid #8844cc;
}

.media-aobadai .stat-badge,
.stat-badge.media-aobadai {
    background: #fde9f3;
    border: 1px solid #cc4488;
}

.media-repeater .stat-badge,
.stat-badge.media-repeater {
    background: #fff9e6;
    border: 1px solid #d4a017;
}

.media-other .stat-badge,
.stat-badge.media-other {
    background: #f2f2f2;
    border: 1px solid #999;
}

.monthly-stats-bar {
    margin: 8px 0 12px;
    padding: 12px;
    background: linear-gradient(135deg, #f8f9ff 0%, #e8f2ff 100%);
    border-radius: 10px;
    border: 1px solid #e0e6ff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.monthly-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.stat-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.stat-badge.active {
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
    transform: scale(1.02);
}

.count-number {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 800;
    min-width: 16px;
    text-align: center;
}

.stat-total {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: #fff;
    border-color: #2c3e50;
    font-size: 13px;
}

.stat-total .count-number {
    background: rgba(255, 255, 255, 0.95);
    color: #2c3e50;
    margin-left: 3px;
}

.media-suumo .stat-badge,
.stat-badge.media-suumo {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border-color: #28a745;
    font-size: 11px;
    padding: 5px 8px;
}

.media-athome .stat-badge,
.stat-badge.media-athome {
    background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
    color: white;
    border-color: #dc3545;
    font-size: 11px;
    padding: 5px 8px;
}

.media-holmes .stat-badge,
.stat-badge.media-holmes {
    background: linear-gradient(135deg, #ff8800 0%, #ff6b35 100%);
    color: white;
    border-color: #ff8800;
    font-size: 11px;
    padding: 5px 8px;
}

.media-jishahp .stat-badge,
.stat-badge.media-jishahp {
    background: linear-gradient(135deg, #3366cc 0%, #2980b9 100%);
    color: white;
    border-color: #3366cc;
    font-size: 11px;
    padding: 5px 8px;
}

.media-nagatsuta .stat-badge,
.stat-badge.media-nagatsuta {
    background: linear-gradient(135deg, #8844cc 0%, #9b59b6 100%);
    color: white;
    border-color: #8844cc;
    font-size: 11px;
    padding: 5px 8px;
}

.media-aobadai .stat-badge,
.stat-badge.media-aobadai {
    background: linear-gradient(135deg, #cc4488 0%, #e84393 100%);
    color: white;
    border-color: #cc4488;
    font-size: 11px;
    padding: 5px 8px;
}

.media-repeater .stat-badge,
.stat-badge.media-repeater {
    background: linear-gradient(135deg, #d4a017 0%, #f39c12 100%);
    color: white;
    border-color: #d4a017;
    font-size: 11px;
    padding: 5px 8px;
}

.media-other .stat-badge,
.stat-badge.media-other {
    background: linear-gradient(135deg, #999999 0%, #7f8c8d 100%);
    color: white;
    border-color: #999999;
    font-size: 11px;
    padding: 5px 8px;
}

.media-ur .stat-badge,
.stat-badge.media-ur {
    background: linear-gradient(135deg, #008b8b 0%, #16a085 100%);
    color: white;
    border-color: #008b8b;
    font-size: 11px;
    padding: 5px 8px;
}

.media-wakabadai .stat-badge,
.stat-badge.media-wakabadai {
    background: linear-gradient(135deg, #8b5a2b 0%, #a0522d 100%);
    color: white;
    border-color: #8b5a2d;
    font-size: 11px;
    padding: 5px 8px;
}

.media-tenpo .stat-badge,
.stat-badge.media-tenpo {
    background: linear-gradient(135deg, #444444 0%, #2c3e50 100%);
    color: white;
    border-color: #444444;
    font-size: 11px;
    padding: 5px 8px;
}

.contracted-count {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 3px 6px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 800;
    margin-left: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.contracted-count .count-number {
    background: rgba(255, 255, 255, 0.95);
    color: #28a745;
    margin-left: 2px;
    font-size: 9px;
    padding: 1px 3px;
}

/* グラフ用スタイル */
.chart-container {
    margin-top: 20px;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-height: 300px;
}

.chart-title {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
}

.chart-bars {
    display: flex;
    align-items: end;
    justify-content: space-around;
    height: 200px;
    margin-bottom: 20px;
    padding: 0 20px;
    gap: 10px;
}

.chart-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 80px;
    min-width: 60px;
}

.chart-bar-wrapper {
    height: 100%;
    display: flex;
    align-items: end;
    margin-bottom: 10px;
    width: 100%;
    justify-content: center;
}

.chart-bar {
    width: 50px;
    border-radius: 8px 8px 0 0;
    position: relative;
    transition: all 0.3s ease;
    min-height: 2px;
}

.chart-bar.total {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
}

.chart-bar.contracted {
    background: linear-gradient(180deg, #28a745 0%, #20c997 100%);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 0 0 8px 8px;
    min-height: 1px;
}

.chart-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 5px;
    text-align: center;
}

.chart-value {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    text-align: center;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.legend-color.total {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.legend-color.contracted {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

/* 統計・ランキングボタンをさらに目立つように */
.search-actions .btn-secondary:nth-child(1),
.search-actions .btn-secondary:nth-child(2) {
    font-size: 16px !important;
    padding: 12px 24px !important;
    border-radius: 30px !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2) !important;
    animation: pulse 2s infinite !important;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.search-actions .btn-secondary:nth-child(2) {
    animation: pulse-orange 2s infinite !important;
}

@keyframes pulse-orange {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 136, 0, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 136, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 136, 0, 0);
    }
}

/* 統計セクションのグラフスタイル強化 */
.statistics-section .chart-container {
    margin-top: 30px;
    padding: 25px;
}

.statistics-section .chart-bars {
    height: 250px;
    margin: 30px 0;
}

.statistics-section .chart-bar {
    width: 60px;
}

/* 目立つボタンスタイル - より目立つ色に変更 */
.btn-secondary {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-secondary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.4);
}

.btn-secondary:active {
    transform: translateY(-1px);
}

/* 統計ボタンの特別なスタイル - より目立つ緑色 */
.search-actions .btn-secondary:nth-child(1) {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
    position: relative;
    overflow: hidden;
}

.search-actions .btn-secondary:nth-child(1):hover {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(40, 167, 69, 0.5);
}

.search-actions .btn-secondary:nth-child(1):active {
    transform: translateY(-1px);
}

/* ランキングボタンの特別なスタイル - より目立つオレンジ色 */
.search-actions .btn-secondary:nth-child(2) {
    background: linear-gradient(135deg, #ff8800 0%, #ff6b35 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(255, 136, 0, 0.4);
    position: relative;
    overflow: hidden;
}

.search-actions .btn-secondary:nth-child(2):hover {
    background: linear-gradient(135deg, #e67300 0%, #e65a00 100%);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(255, 136, 0, 0.5);
}

.search-actions .btn-secondary:nth-child(2):active {
    transform: translateY(-1px);
}

/* バックアップボタンの特別なスタイル - より目立つ青色 */
.search-actions .btn-secondary:nth-child(3) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.search-actions .btn-secondary:nth-child(3):hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.5);
}

/* 統計・ランキングボタンをさらに目立つように */
.search-actions .btn-secondary:nth-child(1),
.search-actions .btn-secondary:nth-child(2) {
    font-size: 16px !important;
    padding: 12px 24px !important;
    border-radius: 30px !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2) !important;
    animation: pulse 2s infinite !important;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.search-actions .btn-secondary:nth-child(2) {
    animation: pulse-orange 2s infinite !important;
}

@keyframes pulse-orange {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 136, 0, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 136, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 136, 0, 0);
    }
}

/* グラフコンテナのスタイル強化 */
.chart-container {
    margin-top: 20px;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-height: 300px;
}

.chart-title {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
}

.chart-bars {
    display: flex;
    align-items: end;
    justify-content: space-around;
    height: 200px;
    margin-bottom: 20px;
    padding: 0 20px;
    gap: 10px;
}

.chart-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 80px;
    min-width: 60px;
}

.chart-bar-wrapper {
    height: 100%;
    display: flex;
    align-items: end;
    margin-bottom: 10px;
    width: 100%;
    justify-content: center;
}

.chart-bar {
    width: 50px;
    border-radius: 8px 8px 0 0;
    position: relative;
    transition: all 0.3s ease;
    min-height: 2px;
}

.chart-bar.total {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
}

.chart-bar.contracted {
    background: linear-gradient(180deg, #28a745 0%, #20c997 100%);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 0 0 8px 8px;
    min-height: 1px;
}

.chart-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 5px;
    text-align: center;
}

.chart-value {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    text-align: center;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.legend-color.total {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.legend-color.contracted {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

/* 統計セクションのグラフスタイル強化 */
.statistics-section .chart-container {
    margin-top: 30px;
    padding: 25px;
}

.statistics-section .chart-bars {
    height: 250px;
    margin: 30px 0;
}

.statistics-section .chart-bar {
    width: 60px;
}

.no-data {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 40px;
}

.log-section h3 {
    margin-bottom: 15px;
    color: #333;
}

.log-container {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.log-entry {
    margin: 5px 0;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 14px;
}

.log-entry.success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.log-entry.error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.log-entry.info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

.header-menu {
    position: absolute;
    top: 20px;
    right: 20px;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    min-width: 200px;
}

.dropdown-menu a {
    display: block;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}

.dropdown-menu a:hover {
    background-color: #f8f9fa;
    color: #667eea;
    transform: translateX(2px);
}

.dropdown-menu a:last-child {
    border-bottom: none;
}

.year-tabs,
.month-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.tab-button {
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

.tab-button.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
}

.tab-button:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.tab-button[data-view="statistics"] {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border-color: #28a745;
    font-weight: 600;
}

.tab-button[data-view="statistics"]:hover {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
    border-color: #1e7e34;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(40, 167, 69, 0.3);
}

.tab-button[data-view="statistics"].active {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
    border-color: #1e7e34;
    box-shadow: 0 6px 16px rgba(40, 167, 69, 0.4);
}

.tab-button[data-view="rankings"] {
    background: linear-gradient(135deg, #ff8800 0%, #ff6b35 100%);
    color: white;
    border-color: #ff8800;
    font-weight: 600;
}

.tab-button[data-view="rankings"]:hover {
    background: linear-gradient(135deg, #e67300 0%, #e65a00 100%);
    border-color: #e67300;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 136, 0, 0.3);
}

.tab-button[data-view="rankings"].active {
    background: linear-gradient(135deg, #e67300 0%, #e65a00 100%);
    border-color: #e67300;
    box-shadow: 0 6px 16px rgba(255, 136, 0, 0.4);
}

.tab-button[data-year] {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
    border-color: #6c757d;
}

.tab-button[data-year]:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
    border-color: #5a6268;
}

.tab-button[data-year].active {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
    border-color: #495057;
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.4);
}

.tab-button[data-month] {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
    border-color: #17a2b8;
    font-size: 13px;
    padding: 8px 16px;
}

.tab-button[data-month]:hover {
    background: linear-gradient(135deg, #138496 0%, #117a8b 100%);
    border-color: #138496;
}

.tab-button[data-month].active {
    background: linear-gradient(135deg, #138496 0%, #117a8b 100%);
    border-color: #117a8b;
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.4);
}

.tab-button::before {
    content: '';
    width: 16px;
    height: 16px;
    display: inline-block;
    margin-right: 4px;
}

.tab-button[data-view="statistics"]::before {
    content: '📊';
}

.tab-button[data-view="rankings"]::before {
    content: '🏆';
}

.tab-button[data-year]::before {
    content: '📅';
}

.tab-button[data-month]::before {
    content: '📆';
}

#other-operations-menu {
    position: absolute;
    top: 20px;
    right: 120px;
}

#other-operations-dropdown {
    min-width: 180px;
}

#other-operations-dropdown a {
    font-size: 14px;
    font-weight: 500;
}

#other-operations-dropdown a:hover {
    background: linear-gradient(135deg, #f8f9ff 0%, #e8f2ff 100%);
    color: #667eea;
}

.statistics-section {
    background: linear-gradient(135deg, #f8f9ff 0%, #e8f2ff 100%);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 40px;
    border: 2px solid #e0e6ff;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.1);
    display: none;
}

.statistics-section.active {
    display: block !important;
}

.statistics-title {
    text-align: center;
    color: #333;
    font-size: 2.5rem;
    margin-bottom: 40px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.statistics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.statistics-card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.statistics-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.2);
}

.statistics-card h4 {
    color: #333;
    font-size: 1.5rem;
    margin-bottom: 25px;
    text-align: center;
    font-weight: 600;
    padding-bottom: 15px;
    border-bottom: 3px solid #667eea;
}

.statistics-card:nth-child(1) h4 {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    font-size: 1.3rem;
    margin-bottom: 20px;
    text-align: center;
    padding-bottom: 15px;
    border-bottom: 3px solid rgba(40, 167, 69, 0.3);
}

.statistics-card:nth-child(2) h4 {
    background: linear-gradient(135deg, #ff8800 0%, #ff6b35 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    font-size: 1.3rem;
    margin-bottom: 20px;
    text-align: center;
    padding-bottom: 15px;
    border-bottom: 3px solid rgba(255, 136, 0, 0.3);
}

.statistics-card:nth-child(3) h4 {
    background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    font-size: 1.3rem;
    margin-bottom: 20px;
    text-align: center;
    padding-bottom: 15px;
    border-bottom: 3px solid rgba(220, 53, 69, 0.3);
}

.statistics-card:nth-child(4) h4 {
    background: linear-gradient(135deg, #3366cc 0%, #2980b9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    font-size: 1.3rem;
    margin-bottom: 20px;
    text-align: center;
    padding-bottom: 15px;
    border-bottom: 3px solid rgba(51, 102, 204, 0.3);
}

.statistics-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.statistics-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border-left: 4px solid #667eea;
    transition: all 0.3s ease;
}

.statistics-item.clickable:hover {
    background: linear-gradient(135deg, #e8f2ff 0%, #d1e3ff 100%);
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.statistics-item.clickable:active {
    transform: translateX(2px);
}

.statistics-item[data-year]:hover {
    cursor: pointer;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.statistics-item[data-year]:hover .statistics-label,
.statistics-item[data-year]:hover .statistics-value,
.statistics-item[data-year]:hover .statistics-contracted {
    color: white;
}

.statistics-item[data-year]:hover .statistics-contracted {
    background: rgba(255, 255, 255, 0.2);
}

.statistics-label {
    font-weight: 600;
    color: #495057;
    font-size: 1.1rem;
}

.statistics-value {
    font-weight: 700;
    color: #667eea;
    font-size: 1.3rem;
}

.statistics-contracted {
    font-size: 0.9rem;
    color: #28a745;
    font-weight: 600;
    background: rgba(40, 167, 69, 0.1);
    padding: 4px 8px;
    border-radius: 8px;
}

.rankings-view {
    background: white;
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: none;
}

.rankings-view.active {
    display: block !important;
}

.rankings-container {
    padding: 20px;
}

.rankings-title {
    text-align: center;
    color: #333;
    font-size: 2.5rem;
    margin-bottom: 40px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.rankings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 768px) {
  .rankings-grid {
    grid-template-columns: 1fr;
  }
}

.rankings-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
    min-height: 400px;
}

.rankings-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

.rankings-card h3 {
    color: #333;
    font-size: 1.4rem;
    margin-bottom: 25px;
    text-align: center;
    font-weight: 600;
    padding-bottom: 15px;
    border-bottom: 3px solid;
}

.rankings-card:nth-child(1) {
    border-top: 4px solid #667eea;
}

.rankings-card:nth-child(1) h3 {
    border-bottom-color: #667eea;
}

.rankings-card:nth-child(2) {
    border-top: 4px solid #28a745;
}

.rankings-card:nth-child(2) h3 {
    border-bottom-color: #28a745;
}

.rankings-card:nth-child(3) {
    border-top: 4px solid #ff8800;
}

.rankings-card:nth-child(3) h3 {
    border-bottom-color: #ff8800;
}

.rankings-card:nth-child(4) {
    border-top: 4px solid #dc3545;
}

.rankings-card:nth-child(4) h3 {
    border-bottom-color: #dc3545;
}

.rankings-card:nth-child(5) {
    border-top: 4px solid #3366cc;
}

.rankings-card:nth-child(5) h3 {
    border-bottom-color: #3366cc;
}

.rankings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border-left: 4px solid #667eea;
    transition: all 0.3s ease;
    cursor: pointer;
}

.ranking-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.ranking-rank {
    font-size: 2rem;
    min-width: 60px;
    text-align: center;
    font-weight: 800;
}

.rank-number {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ranking-info {
    flex: 1;
}

.ranking-property {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.4;
}

.ranking-details {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ranking-count {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    min-width: 80px;
    text-align: center;
}

.no-ranking {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 20px;
    background: rgba(153, 153, 153, 0.05);
    border-radius: 12px;
    margin: 10px 0;
}

.rankings-summary {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

.rankings-summary h3 {
    color: #333;
    font-size: 1.5rem;
    margin-bottom: 25px;
    text-align: center;
    font-weight: 600;
    padding-bottom: 15px;
    border-bottom: 3px solid #667eea;
}

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

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 25px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    border: 1px solid #dee2e6;
    transition: all 0.3s ease;
}

.summary-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.summary-value {
    font-weight: 700;
    color: #667eea;
    font-size: 1.3rem;
}

.summary-label {
    font-weight: 600;
    color: #495057;
    font-size: 1.1rem;
}

.search-container.top-right {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 16px;
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transform: scale(0.9);
    transform-origin: top right;
}

.search-container.top-right input {
    min-width: 250px;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    font-size: 13px;
}

.search-container.top-right button {
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 20px;
}

.year-navigation {
    margin-top: 80px;
    text-align: center;
}

.year-nav-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.year-nav-btn.modern-nav-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.year-nav-btn.modern-nav-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.year-nav-btn.modern-nav-btn:active {
    transform: translateY(-1px);
}

.year-nav-btn.modern-nav-btn .nav-arrow {
    font-size: 20px;
    font-weight: bold;
}

.year-nav-btn.modern-nav-btn .nav-text {
    font-size: 14px;
}

.year-dropdown.modern-dropdown {
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.year-dropdown.modern-dropdown:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.current-year-display {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin-top: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.year-tabs {
    display: none;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.year-tabs.show {
    display: flex;
}

.year-tab {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

.year-tab:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.4);
}

.year-tab.active {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.5);
}

.year-tab .year-count {
    font-size: 12px;
    opacity: 0.9;
    margin-left: 5px;
}

.month-tabs {
    display: none;
    gap: 6px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.month-tabs.show {
    display: flex;
}

.month-tabs.show-months {
    display: flex;
}

.month-tabs .tab-button {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    min-width: 60px;
    text-align: center;
}

.month-tabs .tab-button[data-month=""] {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border-color: #28a745;
    font-weight: 600;
}

.month-tabs .tab-button[data-month=""]:hover {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
    border-color: #1e7e34;
}

.month-tabs .tab-button[data-month=""].active {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
    border-color: #1e7e34;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.month-tabs .tab-button[data-month]:not([data-month=""]) {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
    border-color: #17a2b8;
    font-size: 12px;
    padding: 6px 14px;
}

.month-tabs .tab-button[data-month]:not([data-month=""]):hover {
    background: linear-gradient(135deg, #138496 0%, #117a8b 100%);
    border-color: #138496;
}

.month-tabs .tab-button[data-month]:not([data-month=""]).active {
    background: linear-gradient(135deg, #138496 0%, #117a8b 100%);
    border-color: #117a8b;
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.4);
}

/* クリックできる媒体バッジ用 */
a.media-link.stat-badge { text-decoration: none; cursor: pointer; }
a.media-link.stat-badge:hover { opacity: 0.9; }

/* ランキングテーブルのカラフルデザイン */
.rankings-table {
  border-collapse: separate;
  border-spacing: 0 8px;
  margin-top: 12px;
}

.rankings-table thead th {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  color: #495057;
  font-weight: 700;
  padding: 12px;
  border-bottom: 3px solid #dee2e6;
}

.rankings-table tbody tr {
  border-radius: 12px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.rankings-table tbody tr:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.rankings-table tbody tr.rank-1 {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
  border-left: 6px solid #ffc107;
}

.rankings-table tbody tr.rank-2 {
  background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
  border-left: 6px solid #6c757d;
}

.rankings-table tbody tr.rank-3 {
  background: linear-gradient(135deg, #cd7f32 0%, #e5a44d 100%);
  border-left: 6px solid #a0522d;
}

.rankings-table tbody tr.rank-other {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border-left: 6px solid #667eea;
}

.rankings-table tbody tr.rank-other:nth-child(even) {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.rankings-table tbody tr td {
  padding: 16px 12px;
  vertical-align: middle;
  border: none;
}

.rankings-table tbody tr td:first-child {
  border-radius: 12px 0 0 12px;
  padding-left: 20px;
}

.rankings-table tbody tr td:last-child {
  border-radius: 0 12px 12px 0;
  padding-right: 20px;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 16px;
  color: white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.rank-1 .rank-badge {
  background: linear-gradient(135deg, #ffc107 0%, #ffb300 100%);
  color: #333;
}

.rank-2 .rank-badge {
  background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
}

.rank-3 .rank-badge {
  background: linear-gradient(135deg, #a0522d 0%, #8b4513 100%);
}

.rank-other .rank-badge {
  background: linear-gradient(135deg, #667eea 0%, #5a67d8 100%);
}

/* クリックできる媒体バッジ用 */
a.media-link.stat-badge { text-decoration: none; cursor: pointer; }
a.media-link.stat-badge:hover { opacity: 0.9; transform: translateY(-1px); }

/* 順位のメダル風装飾 */
.rank-1 .rank-badge::before {
  content: '🏆';
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 12px;
  background: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.rank-2 .rank-badge::before {
  content: '🥈';
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 12px;
  background: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.rank-3 .rank-badge::before {
  content: '🥉';
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 12px;
  background: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.rank-badge {
  position: relative;
}

/* モバイル対応 */
@media (max-width: 768px) {
  .rankings-table {
    border-spacing: 0 6px;
  }
  
  .rankings-table tbody tr td {
    padding: 12px 8px;
    font-size: 14px;
  }
  
  .rank-badge {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }
  
  .rankings-table .media-link.stat-badge {
    font-size: 11px;
    padding: 4px 8px;
  }
}

/* チェックボックスラベルのレスポンシブ */
@media (max-width: 480px) {
  #ignoreRoomCheck + label {
    font-size: 13px;
  }
}

/* 媒体バッジの色付けと一行配置 */
.rank-table .cell-medias {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  overflow: hidden;
}

.rank-table .cell-medias .stat-badge {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 15px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.rank-table .cell-medias .stat-badge:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* 媒体別色設定 */
.rank-table .cell-medias .media-suumo {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  color: white;
  border: 1px solid #28a745;
}

.rank-table .cell-medias .media-athome {
  background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
  color: white;
  border: 1px solid #dc3545;
}

.rank-table .cell-medias .media-holmes {
  background: linear-gradient(135deg, #ff8800 0%, #ff6b35 100%);
  color: white;
  border: 1px solid #ff8800;
}

.rank-table .cell-medias .media-jishahp {
  background: linear-gradient(135deg, #3366cc 0%, #2980b9 100%);
  color: white;
  border: 1px solid #3366cc;
}

.rank-table .cell-medias .media-nagatsuta {
  background: linear-gradient(135deg, #8844cc 0%, #9b59b6 100%);
  color: white;
  border: 1px solid #8844cc;
}

.rank-table .cell-medias .media-aobadai {
  background: linear-gradient(135deg, #cc4488 0%, #e84393 100%);
  color: white;
  border: 1px solid #cc4488;
}

.rank-table .cell-medias .media-repeater {
  background: linear-gradient(135deg, #d4a017 0%, #f39c12 100%);
  color: white;
  border: 1px solid #d4a017;
}

.rank-table .cell-medias .media-other {
  background: linear-gradient(135deg, #999999 0%, #7f8c8d 100%);
  color: white;
  border: 1px solid #999999;
}

.rank-table .cell-medias .media-ur {
  background: linear-gradient(135deg, #008b8b 0%, #16a085 100%);
  color: white;
  border: 1px solid #008b8b;
}

.rank-table .cell-medias .media-wakabadai {
  background: linear-gradient(135deg, #8b5a2b 0%, #a0522d 100%);
  color: white;
  border: 1px solid #8b5a2d;
}

.rank-table .cell-medias .media-tenpo {
  background: linear-gradient(135deg, #444444 0%, #2c3e50 100%);
  color: white;
  border: 1px solid #444444;
}

/* カウント数のスタイル */
.rank-table .cell-medias .count-number {
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 800;
  min-width: 16px;
  text-align: center;
  margin-left: 4px;
}

/* モバイル対応 */
@media (max-width: 768px) {
  .rank-table .cell-medias {
    gap: 4px;
  }
  
  .rank-table .cell-medias .stat-badge {
    font-size: 10px;
    padding: 3px 6px;
  }
  
  .rank-table .cell-prop .prop-name {
    font-size: 16px;
  }
  
  .rank-table .cell-total .total-big {
    font-size: 22px;
  }
}

@media (max-width: 480px) {
  .rank-table .cell-medias {
    flex-wrap: wrap;
    gap: 3px;
  }
  
  .rank-table .cell-medias .stat-badge {
    font-size: 9px;
    padding: 2px 5px;
  }
}

/* モーダルスタイル */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
}

/* モーダル本体を「縦flex」化して、ヘッダ/本文/フッタを分離 */
.modal-overlay .modal-content {
  display: flex;
  flex-direction: column;
  width: min(980px, 96vw);
  max-height: 90vh;
  overflow: hidden;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
}

/* 表のある本文エリアだけ縦スクロールにする */
.modal-overlay .modal-content .table-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

/* フッタ（ボタン）は常に見える位置に固定 */
.modal-overlay .modal-content .modal-actions {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  background: #fff;
  padding-top: 8px;
  border-top: 1px solid #eef1f7;
}

/* スクロール時にヘッダ行を見失わないように任意で固定（不要なら削除） */
.modal-overlay .modal-content thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
}

/* 年度UIは廃止（検索は常に全年度） */
/* 以下の非表示スタイルを削除または上書きして表示するように変更 */
.year-navigation {
  display: block !important;
  margin-top: 20px;
  margin-bottom: 20px;
}

#year-selector,
.year-tabs,
#month-tabs {
  /* 個別の要素制御はJSで行うため、一括非表示は解除 */
  display: flex; 
}

/* 前年・翌年・年度選択のコンテナスタイル */
.year-nav-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin: 20px 0;
  padding: 15px;
  background: white;
  border-radius: 50px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.nav-year-btn {
  background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s ease;
}

.nav-year-btn:disabled {
  background: #e9ecef;
  color: #adb5bd;
  cursor: not-allowed;
  box-shadow: none;
}

.nav-year-btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(108, 117, 125, 0.3);
}

.year-select-wrapper select {
  font-size: 18px;
  font-weight: 700;
  color: #333;
  padding: 8px 30px 8px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 25px;
  background-color: white;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  min-width: 120px;
  text-align: center;
}

.year-select-wrapper select:focus {
  border-color: #667eea;
}

/* 媒体タブ（合計・各媒体）のスタイル調整 */
.media-filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.media-filter-btn {
  padding: 8px 16px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  color: #555;
}

.media-filter-btn:hover {
  background: #f8f9fa;
  border-color: #ccc;
}

.media-filter-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

/* 合計タブ（リセットボタン） */
.media-filter-btn.total-tab {
  background: #333;
  color: #fff;
  border-color: #333;
  font-weight: 700;
}

.media-filter-btn.total-tab.active {
  background: #000;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.highlight {
  background: #ffeb3b;
  color: #000;
  font-weight: 700;
  padding: 0 2px;
  border-radius: 3px;
}

/* =========================================
   新しいナビゲーション・UIスタイル
   ========================================= */

/* ツールバーコンテナ */
#app-toolbar {
  background: white;
  padding: 15px 20px;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  position: sticky;
  top: 10px;
  z-index: 900;
}

/* 上段：年度・ビュー切り替え・ツール */
.toolbar-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

/* 年度タブグループ */
.year-nav-group {
  display: flex;
  background: #f1f3f5;
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.year-nav-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-weight: 600;
  color: #495057;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
}

.year-nav-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.5);
  color: #212529;
}

.year-nav-btn.active {
  background: white;
  color: #667eea;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.year-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ビュー切り替えタブ（セグメンテッドコントロール） */
.view-tabs {
  display: flex;
  background: #e9ecef;
  padding: 4px;
  border-radius: 30px;
  gap: 2px;
}

.view-tab-btn {
  padding: 8px 20px;
  border: none;
  background: transparent;
  border-radius: 25px;
  font-weight: 700;
  color: #6c757d;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.view-tab-btn.active {
  background: white;
  color: #667eea;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transform: scale(1.02);
}

.view-tab-btn[data-view="statistics"].active {
  color: #28a745;
}

.view-tab-btn[data-view="rankings"].active {
  color: #ff8800;
}

/* ツールメニューボタン */
.tool-menu-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #f8f9fa;
  color: #495057;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}

.tool-menu-btn:hover, .tool-menu-btn.active {
  background: #e9ecef;
  color: #212529;
}

/* ドロップダウンメニューの改良 */
.modern-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  border: 1px solid #f1f3f5;
  min-width: 220px;
  overflow: hidden;
  z-index: 1000;
  display: none;
  animation: slideDown 0.2s ease;
}

.modern-dropdown.show {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: #495057;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
  cursor: pointer;
  border-bottom: 1px solid #f8f9fa;
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background: #f8f9ff;
  color: #667eea;
}

.dropdown-divider {
  height: 1px;
  background: #e9ecef;
  margin: 4px 0;
}

/* サブナビゲーション（月タブ・フィルタ） */
#view-specific-controls {
  border-top: 1px solid #f1f3f5;
  padding-top: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 月タブスクロールコンテナ */
.scrollable-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}
.scrollable-tabs::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.month-pill {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  background: #f8f9fa;
  color: #6c757d;
  border: 1px solid #dee2e6;
  cursor: pointer;
  transition: all 0.2s;
}

.month-pill:hover {
  background: #e9ecef;
}

.month-pill.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
  box-shadow: 0 2px 6px rgba(102,126,234,0.3);
}

.month-pill[data-month=""] {
  background: #495057;
  color: white;
  border-color: #495057;
}
.month-pill[data-month=""].active {
  background: #212529;
}

/* メディアフィルタバッジ */
.media-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.media-filter-chip {
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #e9ecef;
  background: white;
  color: #495057;
  cursor: pointer;
  transition: all 0.2s;
}

.media-filter-chip:hover {
  background: #f8f9fa;
  transform: translateY(-1px);
}

.media-filter-chip.active {
  background: #edf2ff;
  color: #5c7cfa;
  border-color: #bac8ff;
  font-weight: 700;
}

/* 合計タブは特別扱い */
.media-filter-chip[data-media="ALL"] {
  border-color: #adb5bd;
}
.media-filter-chip[data-media="ALL"].active {
  background: #495057;
  color: white;
  border-color: #495057;
}

/* 検索バー（統合版） */
.unified-search-bar {
  display: flex;
  gap: 8px;
  background: #f8f9fa;
  padding: 6px;
  border-radius: 25px;
  border: 1px solid #e9ecef;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.unified-search-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 4px 12px;
  font-size: 13px;
  outline: none;
}

.unified-search-btn {
  border-radius: 20px;
  padding: 4px 16px;
  font-size: 12px;
}

/* モバイル対応 */
@media (max-width: 768px) {
  .toolbar-top-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .view-tabs {
    order: 2;
    justify-content: center;
    width: 100%;
  }

  .year-nav-group {
    order: 1;
    justify-content: center;
    width: 100%;
  }
  
  .tool-menu-container {
    position: absolute;
    top: 0;
    right: 0;
  }

  .view-tab-btn {
    padding: 8px 12px;
    font-size: 12px;
    flex: 1;
    justify-content: center;
  }
}

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