/* CSS Variables - Light Mode (Default) */
:root {
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --bg-body: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    --color-text: #333;
    --color-text-secondary: #666;
    --color-text-muted: #888;
    --bg-header: rgba(255, 255, 255, 0.95);
    --bg-card: white;
    --bg-card-hover: #f8f9fa;
    --border-color: #ddd;
    --border-light: rgba(255, 255, 255, 0.3);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.1);
    --bg-input: white;
    --bg-table-header: #f8f9fa;
    --bg-table-row-hover: #f0f4ff;
    --chart-grid: rgba(0, 0, 0, 0.1);
    --bg-modal-overlay: rgba(0, 0, 0, 0.5);
    --bg-modal: white;
    --bg-skeleton: #e0e0e0;
    --bg-skeleton-shine: #f0f0f0;
}

/* CSS Variables - Dark Mode */
[data-theme="dark"] {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --bg-body: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    --color-text: #e0e0e0;
    --color-text-secondary: #aaa;
    --color-text-muted: #777;
    --bg-header: rgba(30, 30, 50, 0.95);
    --bg-card: #1e1e2f;
    --bg-card-hover: #2a2a3f;
    --border-color: #3a3a5a;
    --border-light: rgba(255, 255, 255, 0.1);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
    --bg-input: #2a2a3f;
    --bg-table-header: #252540;
    --bg-table-row-hover: #2a2a4a;
    --chart-grid: rgba(255, 255, 255, 0.1);
    --bg-modal-overlay: rgba(0, 0, 0, 0.7);
    --bg-modal: #1e1e2f;
    --bg-skeleton: #2a2a3f;
    --bg-skeleton-shine: #3a3a5a;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-body);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Header */
.header {
    background: var(--bg-header);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background 0.3s ease;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo i {
    font-size: 2rem;
    color: #667eea;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.refresh-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-secondary);
}

.refresh-indicator i {
    animation: spin 2s linear infinite;
}

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

.date-range select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--color-text);
    font-size: 0.9rem;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Main Content */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Section Headers */
section h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 1.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

section h2 i {
    color: #ffd700;
}

/* KPI Section */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.kpi-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}

.kpi-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.kpi-content h3 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 0.25rem;
}

.kpi-change {
    font-size: 0.85rem;
    font-weight: 600;
}

.kpi-change.positive {
    color: #10b981;
}

.kpi-change.negative {
    color: #ef4444;
}

/* Flow Section */
.flow-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
}

.flow-chart {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.flow-metrics {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.flow-step {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.step-content h4 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.step-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #333;
}

.step-rate {
    font-size: 0.85rem;
    color: #10b981;
    font-weight: 600;
}

.flow-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #667eea;
    font-size: 1.2rem;
    font-weight: 600;
}

.flow-arrow i {
    font-size: 1.5rem;
}

/* Campaign Section */
.campaign-container {
    display: grid;
    grid-template-columns: 1fr 500px;
    gap: 2rem;
}

.campaign-chart {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.campaign-table {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(10px);
    overflow: auto;
    transition: background 0.3s ease;
}

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

.campaign-table th,
.campaign-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.campaign-table th {
    font-weight: 600;
    color: var(--color-text);
    background: var(--bg-table-header);
}

.loading {
    text-align: center !important;
    color: #666;
    font-style: italic;
}

/* Real-time Section */
.realtime-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
}

.realtime-chart {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.alert-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.alert-panel h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    margin-bottom: 1rem;
    color: #333;
}

.alert-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
}

.alert-item.normal {
    background: #f0f9ff;
    color: #0891b2;
}

.alert-item.warning {
    background: #fffbeb;
    color: #d97706;
}

.alert-item.critical {
    background: #fef2f2;
    color: #dc2626;
}

.alert-item time {
    margin-left: auto;
    font-size: 0.75rem;
    color: #666;
}

/* Attribution Section */
.attribution-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
}

.attribution-chart {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.attribution-details {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.attribution-details h3 {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 1.5rem;
}

.attribution-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.attribution-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.source-name {
    flex: 1;
    font-weight: 600;
    color: #333;
}

.source-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #667eea;
    margin: 0 1rem;
}

.source-percent {
    font-size: 0.9rem;
    color: #666;
    min-width: 50px;
    text-align: right;
}

/* Footer */
.footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    margin-top: 4rem;
    padding: 2rem 0;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #666;
}

.footer-links {
    display: flex;
    gap: 2rem;
}

.footer-links a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: #764ba2;
}

/* Responsive */
@media (max-width: 1200px) {
    .flow-container,
    .campaign-container,
    .realtime-container,
    .attribution-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Campaign Analysis Enhancements */
.campaign-row td {
    padding: 12px 8px !important;
    line-height: 1.4;
}

.campaign-row small {
    font-size: 0.75rem;
    opacity: 0.8;
}

.high-roi {
    color: #28a745 !important;
    font-weight: bold;
}

.medium-roi {
    color: #ffc107 !important;
    font-weight: bold;
}

.low-roi {
    color: #dc3545 !important;
    font-weight: bold;
}

.open-rate, .click-rate {
    font-weight: 600;
}

/* Campaign Insights */
.insights-container {
    margin-top: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.insight-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem;
    border-left: 4px solid;
}

.insight-card.success {
    border-left-color: #28a745;
}

.insight-card.warning {
    border-left-color: #ffc107;
}

.insight-card.info {
    border-left-color: #17a2b8;
}

.insight-title {
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.insight-message {
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.insight-action {
    font-size: 0.85rem;
    opacity: 0.8;
    font-style: italic;
}

/* FTD Matching Section */
.ftd-matching-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border-light);
    transition: background 0.3s ease;
}

.ftd-matching-section h2 {
    margin-bottom: 1.5rem;
    color: #333;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ftd-matching-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* FTD Controls */
.ftd-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.ftd-controls .btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.ftd-controls .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #555;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

.ftd-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.status-ready {
    color: #28a745;
}

.status-processing {
    color: #ffc107;
    animation: pulse 1.5s infinite;
}

.status-error {
    color: #dc3545;
}

/* FTD Summary Stats */
.ftd-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.ftd-stat-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
}

.ftd-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.ftd-stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.ftd-stat-content h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 0.25rem;
}

.ftd-stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #333;
}

/* FTD Results Table */
.ftd-results {
    margin-top: 1rem;
}

.ftd-results h3 {
    margin-bottom: 1rem;
    color: #333;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.ftd-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.95);
}

.ftd-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.ftd-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

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

.ftd-table .ftd-count {
    font-weight: 600;
    color: #667eea;
}

.ftd-table .ftd-amount {
    font-weight: 600;
    color: #28a745;
}

.ftd-table .conversion-rate {
    font-weight: 600;
}

.ftd-table .roi.positive {
    color: #28a745;
    font-weight: 600;
}

.ftd-table .roi.negative {
    color: #dc3545;
    font-weight: 600;
}

.ftd-table .loading {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
}

/* FTD Insights */
.ftd-insights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.ftd-insights .insight-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 1.5rem;
    border-left: 4px solid;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.ftd-insights .insight-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Responsive Design for FTD Section */
@media (max-width: 768px) {
    .ftd-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .ftd-summary {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    
    .ftd-stat-card {
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .ftd-stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .ftd-stat-value {
        font-size: 1.5rem;
    }
    
    .ftd-insights {
        grid-template-columns: 1fr;
    }
}

/* Animation for processing state */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* SendGrid Diagnostics Panel */
.diagnostics-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1rem 0;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.diagnostics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(102, 126, 234, 0.2);
}

.diagnostics-header h3 {
    margin: 0;
    color: #333;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.diagnostics-timestamp {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

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

.diagnostic-item {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    padding: 1rem;
    border-left: 4px solid;
    transition: all 0.3s ease;
}

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

.diagnostic-item.success {
    border-left-color: #28a745;
    background: rgba(40, 167, 69, 0.1);
}

.diagnostic-item.error {
    border-left-color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
}

.diagnostic-item.warning {
    border-left-color: #ffc107;
    background: rgba(255, 193, 7, 0.1);
}

.diagnostic-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.diagnostic-value {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.diagnostic-item.success .diagnostic-value {
    color: #28a745;
}

.diagnostic-item.error .diagnostic-value {
    color: #dc3545;
}

.diagnostic-item.warning .diagnostic-value {
    color: #e68900;
}

.diagnostic-detail {
    font-size: 0.8rem;
    color: #666;
    opacity: 0.9;
}

.diagnostics-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid rgba(102, 126, 234, 0.1);
}

.diagnostics-actions .btn {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.diagnostics-actions .btn:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.3);
}

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

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

/* Diagnostics Modal */
.diagnostics-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: var(--bg-modal);
    border-radius: 12px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    color: var(--color-text);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow: auto;
}

.modal-body pre {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Responsive design for diagnostics */
@media (max-width: 768px) {
    .diagnostics-grid {
        grid-template-columns: 1fr;
    }
    
    .diagnostics-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .diagnostics-actions .btn {
        justify-content: center;
    }
    
    .modal-content {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
    }
}

/* Customer Journey Analysis Styles */
.customer-journey-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 2rem 0;
    margin: 2rem 0;
    transition: background 0.3s ease;
}

[data-theme="dark"] .customer-journey-section {
    background: linear-gradient(135deg, #1a1a2e 0%, #1e1e3a 100%);
}

.journey-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Journey Map Styles */
.journey-map-container {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.journey-stages {
    display: flex;
    align-items: center;
    gap: 1rem;
    overflow-x: auto;
    padding: 1rem 0;
    min-height: 200px;
}

.journey-stage {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 1.5rem;
    color: white;
    min-width: 180px;
    text-align: center;
    position: relative;
    transition: all 0.3s ease;
}

.journey-stage:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.journey-stage[data-stage="awareness"] {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
}

.journey-stage[data-stage="interest"] {
    background: linear-gradient(135deg, #4ECDC4 0%, #44A08D 100%);
}

.journey-stage[data-stage="consideration"] {
    background: linear-gradient(135deg, #45B7D1 0%, #96C93D 100%);
}

.journey-stage[data-stage="purchase"] {
    background: linear-gradient(135deg, #96CEB4 0%, #FFECD2 100%);
    color: #333;
}

.journey-stage[data-stage="retention"] {
    background: linear-gradient(135deg, #FECA57 0%, #FF9FF3 100%);
}

.stage-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.stage-content h4 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.stage-metric {
    margin-bottom: 0.5rem;
}

.metric-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.metric-label {
    font-size: 0.85rem;
    opacity: 0.9;
}

.stage-conversion {
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.9;
}

.journey-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    color: #667eea;
}

.conversion-rate {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    background: rgba(255, 255, 255, 0.9);
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    white-space: nowrap;
}

/* Funnel Analysis Styles */
.funnel-container {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.funnel-chart {
    height: 300px;
    margin-bottom: 1.5rem;
}

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

.insight-metric {
    text-align: center;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 12px;
    border-left: 4px solid #667eea;
}

.metric-title {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.insight-metric .metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 0.5rem;
}

.metric-description {
    font-size: 0.85rem;
    color: #666;
}

/* Touchpoint Analysis Styles */
.touchpoint-container {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

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

.touchpoint-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.touchpoint-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.touchpoint-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.touchpoint-header i {
    font-size: 1.5rem;
    color: #667eea;
}

.touchpoint-header h4 {
    margin: 0;
    color: #333;
    font-size: 1.1rem;
}

.touchpoint-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.touchpoint-metric {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.touchpoint-metric .metric-label {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.touchpoint-metric .metric-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #333;
}

/* Cross-Channel Analysis Styles */
.cross-channel-container {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.cross-channel-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.channel-matrix {
    height: 300px;
}

.channel-insights h4 {
    margin-bottom: 1.5rem;
    color: #333;
}

.insight-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.insight-item {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #4ECDC4;
}

.insight-title {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.insight-item .insight-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

/* LTV Analysis Styles */
.ltv-container {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.ltv-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    align-items: start;
}

.ltv-chart {
    height: 300px;
}

.ltv-metrics {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.ltv-metric-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
}

.ltv-metric-card h4 {
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ltv-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.ltv-change {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Responsive Design for Customer Journey */
@media (max-width: 1200px) {
    .journey-stages {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .cross-channel-content,
    .ltv-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .journey-stages {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .journey-arrow {
        transform: rotate(90deg);
    }
    
    .touchpoint-grid {
        grid-template-columns: 1fr;
    }
    
    .touchpoint-metrics {
        grid-template-columns: 1fr;
    }
    
    .funnel-insights {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .journey-container {
        padding: 0 0.5rem;
    }
    
    .journey-map-container,
    .funnel-container,
    .touchpoint-container,
    .cross-channel-container,
    .ltv-container {
        padding: 1rem;
    }
    
    .journey-stage {
        min-width: 160px;
        padding: 1rem;
    }
}

/* FTD Retention Analysis Styles */
.ftd-retention-section {
    background: linear-gradient(135deg, #f1f3f4 0%, #e8eaf6 100%);
    padding: 2rem 0;
    margin: 2rem 0;
}

.ftd-retention-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

.retention-summary {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.day-retention-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.day-retention-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border-top: 4px solid #667eea;
}

.day-retention-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.day-retention-card h4 {
    margin: 0 0 1rem 0;
    color: #333;
    text-align: center;
}

.retention-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.retention-metric:last-child {
    border-bottom: none;
}

.retention-metric .metric-label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

.retention-metric .metric-value {
    font-size: 1rem;
    font-weight: 700;
    color: #333;
}

.retention-chart-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    height: 400px;
}

/* Promo Detail Analysis Styles */
.promo-detail-section {
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
    padding: 2rem 0;
    margin: 2rem 0;
}

.promo-detail-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1rem;
}

.promo-chart-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    height: 400px;
}

.promo-detail-table-container {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

.promo-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.promo-detail-table th,
.promo-detail-table td {
    padding: 1rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: top;
}

.promo-detail-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    position: sticky;
    top: 0;
    z-index: 10;
}

.promo-detail-table tbody tr:hover {
    background: #f9f9f9;
}

.promo-segments {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.5rem;
    line-height: 1.4;
}

.retention-breakdown {
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Enhanced Email Analysis Styles */
.email-detail-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 2rem 0;
    margin: 2rem 0;
}

.email-detail-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

.email-chart-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    height: 400px;
}

.email-types-analysis {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.email-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.email-type-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    border-left: 4px solid #667eea;
}

.email-type-card h5 {
    margin: 0 0 1rem 0;
    color: #333;
}

.email-insights-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.insight-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    border-left: 4px solid #28a745;
}

.insight-card h5 {
    margin: 0 0 1rem 0;
    color: #333;
}

.insight-card ul {
    margin: 0;
    padding-left: 1.5rem;
}

.insight-card li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.email-analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.email-analysis-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    transition: background 0.3s ease;
}

.email-analysis-card h4 {
    margin: 0 0 1rem 0;
    color: var(--color-text);
}

.device-stats {
    display: flex;
    gap: 1rem;
}

.device-stat {
    flex: 1;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
}

.device-stat h6 {
    margin: 0 0 0.5rem 0;
    color: #333;
}

.device-stat p {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
}

.subject-line-analysis {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

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

.subject-metric {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
}

.subject-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.subject-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Responsive Design for Detailed Analysis */
@media (max-width: 1200px) {
    .email-analysis-grid {
        grid-template-columns: 1fr;
    }
    
    .device-stats {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .day-retention-grid {
        grid-template-columns: 1fr;
    }
    
    .email-type-grid {
        grid-template-columns: 1fr;
    }
    
    .subject-insights {
        grid-template-columns: 1fr;
    }
    
    .promo-detail-table-container {
        padding: 1rem;
    }
    
    .promo-detail-table {
        font-size: 0.8rem;
    }
    
    .promo-detail-table th,
    .promo-detail-table td {
        padding: 0.75rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .ftd-retention-container,
    .promo-detail-container,
    .email-detail-container {
        padding: 0 0.5rem;
    }
    
    .retention-summary,
    .email-types-analysis,
    .email-insights-container,
    .subject-line-analysis {
        padding: 1rem;
    }
    
    .day-retention-card,
    .email-analysis-card {
        padding: 1rem;
    }
}

/* FTD Acquisition Analysis Styles */
.ftd-acquisition-section {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    padding: 2rem 0;
    margin: 2rem 0;
}

.ftd-acquisition-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

.acquisition-summary {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.summary-metric {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    border-left: 4px solid #2196F3;
}

.summary-metric .metric-label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-metric .metric-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

.day-acquisition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.day-acquisition-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border-top: 4px solid #2196F3;
}

.day-acquisition-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.day-acquisition-card h4 {
    margin: 0 0 1rem 0;
    color: #333;
    text-align: center;
}

.acquisition-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.acquisition-metric:last-child {
    border-bottom: none;
}

.acquisition-metric .metric-label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

.acquisition-metric .metric-value {
    font-size: 1rem;
    font-weight: 700;
    color: #333;
}

.acquisition-chart-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    height: 400px;
}

/* FTD Email Campaigns Styles */
.ftd-email-campaigns-section {
    background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
    padding: 2rem 0;
    margin: 2rem 0;
}

.ftd-email-campaigns-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1rem;
}

.email-funnel-chart-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    height: 400px;
}

.ftd-campaigns-table-container {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

.ftd-campaigns-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.ftd-campaigns-table th,
.ftd-campaigns-table td {
    padding: 1rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: top;
}

.ftd-campaigns-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    position: sticky;
    top: 0;
    z-index: 10;
}

.ftd-campaigns-table tbody tr:hover {
    background: #f9f9f9;
}

.campaign-day {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
}

.campaign-segment {
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.25rem;
    font-style: italic;
}

.ftd-rate {
    font-size: 0.9rem;
    color: #28a745;
    font-weight: 600;
}

.bonus-amount {
    font-size: 0.8rem;
    color: #667eea;
    font-weight: 500;
}

/* Post-FTD Retention Styles */
.post-ftd-retention-section {
    background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
    padding: 2rem 0;
    margin: 2rem 0;
}

.post-ftd-retention-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

.post-ftd-summary {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.post-ftd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.post-ftd-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border-top: 4px solid #4caf50;
}

.post-ftd-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.post-ftd-card h4 {
    margin: 0 0 1rem 0;
    color: #333;
    text-align: center;
}

.post-ftd-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.post-ftd-metric:last-child {
    border-bottom: none;
}

.post-ftd-metric .metric-label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

.post-ftd-metric .metric-value {
    font-size: 1rem;
    font-weight: 700;
    color: #333;
}

.post-ftd-chart-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    height: 400px;
}

/* Responsive Design for FTD Analysis */
@media (max-width: 1200px) {
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .day-acquisition-grid,
    .post-ftd-grid {
        grid-template-columns: 1fr;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
    }
    
    .ftd-campaigns-table-container {
        padding: 1rem;
    }
    
    .ftd-campaigns-table {
        font-size: 0.8rem;
    }
    
    .ftd-campaigns-table th,
    .ftd-campaigns-table td {
        padding: 0.75rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .ftd-acquisition-container,
    .ftd-email-campaigns-container,
    .post-ftd-retention-container {
        padding: 0 0.5rem;
    }
    
    .acquisition-summary,
    .post-ftd-summary {
        padding: 1rem;
    }
    
    .day-acquisition-card,
    .post-ftd-card {
        padding: 1rem;
    }
}/* Gmail 履歴セクション専用CSS */

.beta-badge {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    margin-left: 0.5rem;
}

.gmail-history-section {
    margin-bottom: 3rem;
}

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

.gmail-stat-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.gmail-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

.gmail-stat-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.gmail-stat-content h3 {
    font-size: 0.9rem;
    color: #666;
    margin: 0 0 0.5rem 0;
    font-weight: 500;
}

.gmail-stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 0.25rem;
}

.gmail-stat-change {
    font-size: 0.8rem;
    color: #28a745;
}

.gmail-filters {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.gmail-filter-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.gmail-filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.gmail-filter-group label {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.gmail-filter-input {
    padding: 0.5rem 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 140px;
    transition: border-color 0.3s ease;
}

.gmail-filter-input:focus {
    outline: none;
    border-color: #667eea;
}

.gmail-table-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.gmail-table-header {
    padding: 1.5rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gmail-table-header h3 {
    margin: 0;
    color: #333;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gmail-table-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.gmail-count {
    font-size: 0.9rem;
    color: #666;
}

.btn-export {
    background: linear-gradient(45px, #28a745, #20c997);
    border: none;
    color: white;
}

.gmail-table-wrapper {
    overflow-x: auto;
}

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

.gmail-table th {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.gmail-table th:hover {
    background: linear-gradient(45deg, #5a6fd8, #6a42a0);
}

.gmail-table th i.fas.fa-sort {
    margin-left: 0.5rem;
    opacity: 0.7;
}

.gmail-table td {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
}

.gmail-table tr:hover {
    background-color: #f8f9ff;
    cursor: pointer;
}

.gmail-subject {
    font-weight: 600;
    color: #333;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gmail-to {
    color: #666;
    font-size: 0.9rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gmail-date {
    color: #888;
    font-size: 0.9rem;
    white-space: nowrap;
}

.gmail-reply-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gmail-reply-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

.gmail-reply-yes {
    background: #d4edda;
    color: #155724;
}

.gmail-reply-no {
    background: #f8d7da;
    color: #721c24;
}

.gmail-promo-badge {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
}

.gmail-loading {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.gmail-loading i {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #667eea;
}

.gmail-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem;
    border-top: 1px solid #f0f0f0;
}

.gmail-page-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    background: white;
    color: #666;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gmail-page-btn:hover, .gmail-page-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.gmail-page-btn:disabled {
    background: #f5f5f5;
    color: #ccc;
    cursor: not-allowed;
}

/* Gmail モーダル */
.gmail-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.gmail-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    max-width: 900px;
    max-height: 80vh;
    width: 90%;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.gmail-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.gmail-modal-title {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gmail-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.gmail-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.gmail-modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.gmail-loading-modal {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.gmail-loading-modal i {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #667eea;
}

.gmail-email-detail {
    margin-bottom: 1.5rem;
}

.gmail-detail-row {
    display: flex;
    margin-bottom: 0.5rem;
}

.gmail-detail-label {
    font-weight: bold;
    width: 100px;
    color: #666;
    flex-shrink: 0;
}

.gmail-detail-value {
    flex: 1;
    color: #333;
}

.gmail-email-body {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
}

.gmail-replies-section {
    margin-top: 2rem;
    border-top: 1px solid #e0e0e0;
    padding-top: 1rem;
}

.gmail-reply-item {
    background: #f0f7ff;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 4px solid #667eea;
}

.gmail-reply-header {
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #333;
}

.gmail-reply-meta {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.gmail-reply-body {
    background: white;
    padding: 0.75rem;
    border-radius: 4px;
    white-space: pre-wrap;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .gmail-filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .gmail-filter-group {
        width: 100%;
    }
    
    .gmail-filter-input {
        min-width: auto;
    }
    
    .gmail-table-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .gmail-table-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .gmail-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .gmail-modal-body {
        max-height: 70vh;
    }
}

/* No Data State Styling */
.no-data-message {
    text-align: center;
    padding: 3rem 2rem;
    color: #666;
    background: #f9f9f9;
    border-radius: 8px;
    margin: 1rem 0;
}

.no-data-message i {
    font-size: 2rem;
    color: #ff6b6b;
    margin-bottom: 1rem;
    display: block;
}

.no-data-message p {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #333;
}

.no-data-message small {
    font-size: 0.9rem;
    color: #777;
}

/* Email Template Section */
.email-template-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    transition: background 0.3s ease;
}

.template-container {
    margin-top: 1.5rem;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.template-card {
    background: #f8f9ff;
    border: 1px solid #e0e3f0;
    border-radius: 8px;
    padding: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.template-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.template-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.template-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-right: 1rem;
}

.template-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.template-subject {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.75rem;
    margin: 0.5rem 0;
    font-size: 0.95rem;
    color: #333;
    font-weight: 500;
}

.template-preview {
    background: #f5f5f5;
    border-left: 4px solid #667eea;
    padding: 0.75rem;
    margin: 0.5rem 0;
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

.template-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e3f0;
}

.template-stat {
    text-align: center;
}

.template-stat-label {
    font-size: 0.8rem;
    color: #666;
    display: block;
}

.template-stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    display: block;
    margin-top: 0.2rem;
}

.template-conversion-rate {
    color: #28a745 !important;
}

.template-amount {
    color: #007bff !important;
}

/* FTD Controls Styling */
.ftd-control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 1rem;
}

.ftd-control-group label {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.ftd-date-select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    color: #333;
    font-size: 0.9rem;
    min-width: 120px;
    cursor: pointer;
}

.ftd-date-select:hover {
    border-color: #667eea;
}

.ftd-date-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.ftd-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9ff;
    border-radius: 8px;
    border: 1px solid #e0e3f0;
}

/* Template Modal Styling */
.template-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.template-modal-content {
    background: white;
    margin: 2% auto;
    padding: 0;
    border-radius: 16px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.template-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 16px 16px 0 0;
}

.template-modal-title {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.template-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.template-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.template-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 75vh;
}

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

.template-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.template-info-item label {
    font-weight: 600;
    color: #666;
    font-size: 0.9rem;
}

.template-info-item span {
    font-size: 1rem;
    color: #333;
    font-weight: 500;
}

.template-preview-section h3 {
    margin: 1.5rem 0 0.8rem 0;
    color: #333;
    font-size: 1.1rem;
    border-left: 4px solid #667eea;
    padding-left: 1rem;
}

.template-subject {
    background: #f8f9ff;
    border: 1px solid #e0e3f0;
    border-radius: 8px;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 500;
    color: #333;
}

.template-preview-text {
    background: #f0f7ff;
    border: 1px solid #c2e3ff;
    border-left: 4px solid #007bff;
    border-radius: 8px;
    padding: 1rem;
    font-size: 0.95rem;
    color: #555;
    font-style: italic;
}

.template-view-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1.5rem 0 0.8rem 0;
}

.template-view-controls h3 {
    margin: 0;
    color: #333;
    font-size: 1.1rem;
    border-left: 4px solid #667eea;
    padding-left: 1rem;
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
}

.view-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.view-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.view-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.template-display {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    min-height: 400px;
}

.template-preview-frame {
    width: 100%;
    min-height: 400px;
    background: white;
    overflow: auto;
}

.template-preview-frame iframe {
    width: 100%;
    height: 500px;
    border: none;
    background: white;
}

.template-code-view {
    background: #f5f5f5;
    padding: 1.5rem;
    min-height: 400px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    overflow: auto;
    white-space: pre-wrap;
}

.html-loading {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
}

/* Table row clickable styling */
.ftd-table tbody tr {
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.ftd-table tbody tr:hover {
    background-color: #f0f7ff !important;
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
    z-index: 1;
}

.ftd-table tbody tr:hover td:first-child::after {
    content: " 👁️";
    color: #667eea;
    font-size: 0.9rem;
}

.ftd-table th small {
    font-weight: normal;
    font-size: 0.8rem;
}

/* ======== Dark Mode Toggle Button ======== */
.theme-toggle {
    position: relative;
    width: 48px;
    height: 26px;
    border-radius: 13px;
    background: #ddd;
    border: none;
    cursor: pointer;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    padding: 0 3px;
}

.theme-toggle::after {
    content: '';
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
}

[data-theme="dark"] .theme-toggle {
    background: #667eea;
}

[data-theme="dark"] .theme-toggle::after {
    transform: translateX(22px);
}

.theme-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle-icon {
    font-size: 1rem;
    color: var(--color-text-secondary);
}

/* ======== Dark Mode Section Overrides ======== */
[data-theme="dark"] .ftd-retention-section {
    background: linear-gradient(135deg, #1a1a2e 0%, #1e1e3e 100%);
}
[data-theme="dark"] .promo-detail-section {
    background: linear-gradient(135deg, #1a1a2e 0%, #222238 100%);
}
[data-theme="dark"] .email-detail-section {
    background: linear-gradient(135deg, #1a1a2e 0%, #1e1e3a 100%);
}
[data-theme="dark"] .ftd-acquisition-section {
    background: linear-gradient(135deg, #0d1b2a 0%, #1b2838 100%);
}
[data-theme="dark"] .ftd-email-campaigns-section {
    background: linear-gradient(135deg, #1a1025 0%, #2a1a3a 100%);
}
[data-theme="dark"] .post-ftd-retention-section {
    background: linear-gradient(135deg, #0a1a0a 0%, #1a2a1a 100%);
}

[data-theme="dark"] .template-modal-content {
    background: var(--bg-modal);
}
[data-theme="dark"] .template-modal-body {
    color: var(--color-text);
}
[data-theme="dark"] .template-subject,
[data-theme="dark"] .template-preview-text {
    background: var(--bg-card-hover);
    border-color: var(--border-color);
    color: var(--color-text);
}
[data-theme="dark"] .template-code-view {
    background: #1a1a2e;
    color: #e0e0e0;
}
[data-theme="dark"] .view-btn {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--color-text);
}
[data-theme="dark"] .ftd-controls {
    background: var(--bg-card-hover);
    border-color: var(--border-color);
}
[data-theme="dark"] .ftd-date-select {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--color-text);
}
[data-theme="dark"] .ftd-control-group label {
    color: var(--color-text);
}
[data-theme="dark"] .gmail-reply-item {
    background: var(--bg-card-hover);
}
[data-theme="dark"] .gmail-replies-section {
    border-color: var(--border-color);
}
[data-theme="dark"] .ftd-table tbody tr:hover {
    background-color: var(--bg-table-row-hover) !important;
}
[data-theme="dark"] .template-info-item label {
    color: var(--color-text-secondary);
}
[data-theme="dark"] .template-info-item span {
    color: var(--color-text);
}
[data-theme="dark"] .template-preview-section h3,
[data-theme="dark"] .template-view-controls h3 {
    color: var(--color-text);
}
[data-theme="dark"] .template-stat-label {
    color: var(--color-text-secondary);
}
[data-theme="dark"] .template-stat-value {
    color: var(--color-text);
}
[data-theme="dark"] section h2 {
    color: var(--color-text);
}

/* ======== Loading Skeleton Styles ======== */
.skeleton {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    background: linear-gradient(90deg, var(--bg-skeleton) 25%, var(--bg-skeleton-shine) 50%, var(--bg-skeleton) 75%);
    background-size: 200% 100%;
    border-radius: 4px;
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.skeleton-text-short {
    width: 60%;
}

.skeleton-kpi-value {
    height: 2rem;
    width: 80px;
    border-radius: 6px;
}

.skeleton-chart {
    height: 250px;
    border-radius: 12px;
    margin: 1rem 0;
}

.skeleton-row {
    height: 3rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
}

.loading-overlay {
    position: relative;
}

.loading-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    border-radius: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

[data-theme="dark"] .loading-overlay::after {
    background: rgba(30, 30, 47, 0.7);
}

.section-loading {
    padding: 2rem;
    text-align: center;
}

.section-loading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-skeleton);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

.section-loading-text {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

/* ======== Error Display Styles ======== */
.error-container {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow-card);
    border-left: 4px solid #ef4444;
}

.error-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.error-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.error-message {
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.error-retry-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.error-retry-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.error-details-toggle {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    text-decoration: underline;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.error-details {
    background: var(--bg-table-header);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.75rem;
    text-align: left;
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    max-height: 150px;
    overflow-y: auto;
    display: none;
}

.error-details.show {
    display: block;
}

/* Offline Banner */
.offline-banner {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 0.5rem 1rem;
    text-align: center;
    font-weight: 500;
    font-size: 0.9rem;
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.offline-banner.show {
    display: flex;
}

.offline-banner.hidden {
    display: none;
}

/* Demo Data Badge */
.demo-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: demo-pulse 2s ease-in-out infinite;
}

@keyframes demo-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ======== Segment & Automation Section ======== */
.segment-automation-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    margin-top: 2rem;
    box-shadow: var(--shadow-card);
}

.segment-automation-section h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

.segment-automation-section h2 i {
    color: #667eea;
}

.segment-automation-container .tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.segment-automation-container .tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.segment-automation-container .tab-btn:hover {
    color: var(--color-text);
}

.segment-automation-container .tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Segment Engine Styles */
.segment-rule-editor {
    padding: 1rem;
}

.segment-rule-editor h3 {
    margin-bottom: 1rem;
    color: var(--color-text);
}

.rule-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.rule-item {
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}

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

.rule-name {
    font-size: 1rem;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--color-text);
    width: 70%;
}

.rule-description {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 1rem;
    background: var(--bg-input);
    color: var(--color-text);
    resize: vertical;
    min-height: 60px;
}

.conditions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.condition-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.condition-item select,
.condition-item input {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--color-text);
}

.condition-variable {
    flex: 2;
}

.condition-operator {
    flex: 1;
}

.condition-value {
    flex: 2;
}

.rule-action {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--color-text);
}

/* Automation Engine Styles */
.automation-panel {
    padding: 1rem;
}

.automation-panel h3 {
    margin-bottom: 1rem;
    color: var(--color-text);
}

.automation-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-card-hover);
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.workflow-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.workflow-item {
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
}

.workflow-item.enabled {
    border-left: 4px solid #22c55e;
}

.workflow-item.disabled {
    border-left: 4px solid #ef4444;
    opacity: 0.7;
}

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

.workflow-header h4 {
    margin: 0;
    color: var(--color-text);
}

.workflow-item p {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.workflow-details {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.workflow-details span {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.workflow-details i {
    margin-right: 0.3rem;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
    background-color: #22c55e;
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Buttons */
.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Dark mode adjustments */
[data-theme="dark"] .rule-item,
[data-theme="dark"] .workflow-item,
[data-theme="dark"] .automation-status {
    background: var(--bg-card);
}

/* ===== 同期設定モーダル ===== */
.sync-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-modal-overlay);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.sync-modal.active {
    display: flex;
}

.sync-modal-content {
    background: var(--bg-modal);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
}

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

.sync-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: white;
}

.sync-modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sync-close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.sync-close-btn:hover {
    background: rgba(255,255,255,0.3);
}

.sync-modal-body {
    padding: 2rem;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

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

/* 同期設定グループ */
.sync-setting-group {
    margin-bottom: 2rem;
}

.sync-setting-group:last-child {
    margin-bottom: 0;
}

.sync-setting-group h3 {
    font-size: 1.1rem;
    color: var(--color-text);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sync-setting-group h3 i {
    color: var(--bg-gradient-start);
}

/* 同期オプション */
.sync-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sync-option {
    display: flex;
    flex-direction: column;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-card);
}

.sync-option:hover {
    border-color: var(--bg-gradient-start);
    background: var(--bg-table-row-hover);
}

.sync-option input[type="radio"] {
    display: none;
}

.sync-option input[type="radio"]:checked + .option-title,
.sync-option:has(input:checked) {
    border-color: var(--bg-gradient-start);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

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

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

/* データ種別設定 */
.data-type-settings {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.data-type-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.data-type-name {
    flex: 1;
    font-weight: 500;
    color: var(--color-text);
}

.data-type-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--color-text);
    font-size: 0.9rem;
    cursor: pointer;
    min-width: 120px;
}

.data-type-select:focus {
    outline: none;
    border-color: var(--bg-gradient-start);
}

.data-type-desc {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    min-width: 100px;
}

/* 同期ステータスパネル */
.sync-status-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.5rem;
}

.sync-status-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

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

.status-value {
    font-weight: 600;
    color: var(--color-text);
}

/* ヘッダー同期コントロール */
.sync-controls {
    display: flex;
    gap: 0.5rem;
    margin-right: 1rem;
}

.btn-sync {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sync:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-sync:active {
    transform: translateY(0);
}

.btn-sync:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-settings {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-settings:hover {
    background: var(--bg-table-row-hover);
    color: var(--bg-gradient-start);
    border-color: var(--bg-gradient-start);
}

/* ボタン共通 */
.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--color-text);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-table-row-hover);
}

.btn-primary {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}