/* ==========================================
   signalHub - 青ベース上品デザイン
   ========================================== */

:root {
    /* カラーパレット - 青ベース上品 */
    --primary-blue: #2563eb;
    --primary-blue-dark: #1e40af;
    --primary-blue-light: #3b82f6;
    --secondary-blue: #60a5fa;
    --accent-blue: #93c5fd;
    --bg-blue: #eff6ff;
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #06b6d4;
    
    --shadow-sm: 0 1px 2px 0 rgba(37, 99, 235, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(37, 99, 235, 0.08), 0 2px 4px -1px rgba(37, 99, 235, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(37, 99, 235, 0.1), 0 4px 6px -2px rgba(37, 99, 235, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(37, 99, 235, 0.1), 0 10px 10px -5px rgba(37, 99, 235, 0.04);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 15px;
}

/* ==========================================
   ヘッダー
   ========================================== */
.header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    color: white;
    padding: 2rem 0;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.app-title {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.app-subtitle {
    font-size: 0.95rem;
    opacity: 0.95;
    font-weight: 400;
}

/* ==========================================
   コンテナ
   ========================================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

.screen-header {
    margin-bottom: 2rem;
}

.screen-header h2 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.screen-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ==========================================
   アップロード画面
   ========================================== */
.upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.upload-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.upload-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-blue);
}

.upload-card.loaded {
    border-color: var(--primary-blue);
    background: linear-gradient(to bottom, var(--bg-primary), var(--bg-blue));
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.clear-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.clear-btn:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-secondary);
}

.upload-area:hover {
    border-color: var(--primary-blue);
    background: var(--bg-blue);
}

.upload-area.dragover {
    border-color: var(--primary-blue);
    background: var(--bg-blue);
    transform: scale(1.02);
}

.upload-prompt {
    pointer-events: none;
}

.upload-text {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.upload-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.file-info {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-blue);
    border-radius: var(--radius-sm);
    color: var(--primary-blue);
    font-size: 0.9rem;
    border: 1px solid var(--accent-blue);
}

.upload-progress {
    margin-top: 1rem;
}

.progress-bar {
    height: 4px;
    background: var(--accent-blue);
    border-radius: 2px;
    animation: progress 1.5s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* ==========================================
   列マッピング
   ========================================== */
.mapping-section {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
}

.mapping-section h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.mapping-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.mapping-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.mapping-item {
    display: flex;
    flex-direction: column;
}

.mapping-item label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.mapping-item select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
}

.mapping-item select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ==========================================
   アクションバー
   ========================================== */
.action-bar {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

.btn-primary, .btn-secondary {
    padding: 0.75rem 1.75rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.3px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-blue-dark) 0%, #1e3a8a 100%);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: var(--text-light);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--primary-blue);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-blue);
    border-color: var(--primary-blue);
}

/* ==========================================
   KPI カード
   ========================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.kpi-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-blue);
    margin-bottom: 0.25rem;
}

.kpi-sub {
    font-size: 0.8rem;
    color: var(--text-light);
}

.kpi-card.highlight {
    border-color: var(--primary-blue);
    background: linear-gradient(to bottom, var(--bg-primary), var(--bg-blue));
}

.kpi-card.warning {
    border-color: var(--warning);
}

.kpi-card.warning .kpi-value {
    color: var(--warning);
}

/* ==========================================
   フィルタ
   ========================================== */
.view-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.view-select, .filter-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.view-select:focus, .filter-select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    border-radius: 999px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.filter-chip:hover {
    border-color: var(--primary-blue);
    background: var(--bg-blue);
}

.filter-chip.active {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ==========================================
   テーブル
   ========================================== */
.table-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    max-height: 600px;
    overflow-y: auto;
}

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

.data-table thead {
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    color: white;
    z-index: 10;
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.3px;
}

.data-table td {
    padding: 0.875rem 1rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: var(--bg-blue);
}

.diff-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.diff-badge.new {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.diff-badge.gone {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.diff-badge.month {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info);
}

.diff-badge.amount {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.diff-badge.stage {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-badge.completed {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-badge.uncompleted {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.change-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.btn-edit {
    padding: 0.375rem 0.875rem;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.btn-edit:hover {
    background: var(--primary-blue-dark);
}

/* ==========================================
   モバイル営業画面
   ========================================== */
.person-selector {
    margin-top: 1rem;
}

.person-select {
    width: 100%;
    max-width: 300px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
}

.personal-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.diff-cards {
    display: grid;
    gap: 1rem;
}

.diff-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.diff-card:hover {
    box-shadow: var(--shadow-md);
}

.diff-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.diff-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.diff-card-id {
    font-size: 0.8rem;
    color: var(--text-light);
}

.diff-card-body {
    margin-bottom: 1rem;
}

.diff-card-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.diff-card-row:last-child {
    border-bottom: none;
}

.diff-card-label {
    color: var(--text-secondary);
}

.diff-card-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

.reason-status {
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.reason-status.completed {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.reason-status.uncompleted {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

/* ==========================================
   モーダル
   ========================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.deal-info {
    background: var(--bg-blue);
    border: 1px solid var(--accent-blue);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.deal-info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.375rem 0;
    font-size: 0.9rem;
}

.deal-info-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.deal-info-value {
    color: var(--text-primary);
    font-weight: 600;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.required {
    color: var(--error);
    font-weight: 600;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* ==========================================
   トースト
   ========================================== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--text-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    z-index: 2000;
    opacity: 0;
    transform: translateY(20px);
    transition: var(--transition);
    pointer-events: none;
    max-width: 400px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

.toast.warning {
    background: var(--warning);
}

/* ==========================================
   レスポンシブ
   ========================================== */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem 2rem;
    }
    
    .header-content {
        padding: 0 1rem;
    }
    
    .app-title {
        font-size: 1.5rem;
    }
    
    .upload-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .mapping-grid {
        grid-template-columns: 1fr;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .action-bar {
        flex-direction: column-reverse;
    }
    
    .btn-primary, .btn-secondary {
        width: 100%;
    }
    
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .data-table {
        font-size: 0.85rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
    }
    
    .toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 1.25rem;
    }
    
    .kpi-value {
        font-size: 1.5rem;
    }
    
    .screen-header h2 {
        font-size: 1.35rem;
    }
}
