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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    padding: 20px;
    color: #e0e0e0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
    margin-bottom: 10px;
    color: #b0b0b0;
}

.last-update {
    font-size: 0.9em;
    opacity: 0.8;
    color: #a0a0a0;
}

.controls {
    text-align: center;
    margin-bottom: 20px;
}

.btn {
    padding: 12px 24px;
    font-size: 1em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

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

.htmx-indicator {
    display: none;
    margin-left: 10px;
    color: white;
    font-weight: 600;
}

.htmx-request .htmx-indicator {
    display: inline;
}

/* 要約セクション */
.summary-section {
    margin-bottom: 30px;
}

.summary-box {
    background: rgba(30, 30, 46, 0.9);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
    border: 1px solid rgba(102, 126, 234, 0.3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.summary-title {
    font-size: 1.5em;
    color: #667eea;
    margin-bottom: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.4);
}

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

.summary-card {
    background: rgba(20, 20, 30, 0.6);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
}

.summary-card:hover {
    background: rgba(20, 20, 30, 0.8);
    border-color: rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.summary-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.summary-stock-name {
    font-size: 1.2em;
    color: #ffffff;
    font-weight: 700;
    margin-bottom: 5px;
}

.summary-stock-code {
    font-size: 0.9em;
    color: #b0b0b0;
    background: rgba(102, 126, 234, 0.2);
    padding: 4px 8px;
    border-radius: 5px;
    font-weight: 600;
    border: 1px solid rgba(102, 126, 234, 0.3);
    display: inline-block;
    margin-right: 8px;
}

.summary-adr-symbol {
    font-size: 0.85em;
    color: #a0a0a0;
    font-weight: 600;
}

.summary-data {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.summary-label {
    font-size: 0.85em;
    color: #a0a0a0;
    font-weight: 600;
    flex: 1;
}

.summary-value {
    font-size: 1em;
    color: #e0e0e0;
    font-weight: 700;
    text-align: right;
    flex: 1;
}

.summary-value.positive {
    color: #ef4444;
}

.summary-value.negative {
    color: #3b82f6;
}

.summary-value.neutral {
    color: #94a3b8;
}

.stocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.stock-card {
    background: rgba(30, 30, 46, 0.8);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    backdrop-filter: blur(10px);
}

.stock-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.3);
    border-color: rgba(102, 126, 234, 0.5);
}

.stock-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.stock-name {
    font-size: 1.5em;
    color: #ffffff;
    font-weight: 700;
}

.stock-code {
    font-size: 1em;
    color: #b0b0b0;
    background: rgba(102, 126, 234, 0.2);
    padding: 5px 10px;
    border-radius: 5px;
    font-weight: 600;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.stock-symbol {
    font-size: 0.9em;
    color: #a0a0a0;
    margin-bottom: 15px;
    font-weight: 600;
}

.data-section {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(20, 20, 30, 0.6);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.data-section h3 {
    font-size: 1.1em;
    color: #667eea;
    margin-bottom: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.data-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.label {
    font-weight: 600;
    color: #b0b0b0;
    flex: 1;
}

.value {
    font-weight: 700;
    color: #e0e0e0;
    text-align: right;
    flex: 1;
}

.value.positive {
    color: #ef4444;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.value.negative {
    color: #3b82f6;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.value.neutral {
    color: #94a3b8;
}

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

.timestamp {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    color: #888;
    font-size: 0.85em;
}

.chart-section {
    margin-top: 20px;
    padding: 15px;
    background: rgba(20, 20, 30, 0.6);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.chart-section h3 {
    font-size: 1.1em;
    color: #667eea;
    margin-bottom: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stock-chart {
    width: 100% !important;
    height: 250px !important;
    max-height: 250px;
    background: rgba(10, 10, 20, 0.5);
    border-radius: 8px;
    padding: 10px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: white;
    font-size: 1.2em;
}

/* Chart.js ダークモード対応 */
canvas {
    filter: brightness(0.9) contrast(1.1);
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .stocks-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    header {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .stock-card {
        padding: 15px;
        border-radius: 12px;
    }
    
    .stock-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .stock-name {
        font-size: 1.3em;
    }
    
    .stock-code {
        font-size: 0.9em;
    }
    
    .data-section {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .data-section h3 {
        font-size: 1em;
        margin-bottom: 10px;
    }
    
    .data-row {
        flex-direction: column;
        padding: 10px 0;
        gap: 5px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .data-row:last-child {
        border-bottom: none;
    }
    
    .label {
        font-size: 0.9em;
        color: #a0a0a0;
    }
    
    .value {
        text-align: left;
        font-size: 1.1em;
    }
    
    .chart-section {
        padding: 12px;
    }
    
    .stock-chart {
        height: 200px !important;
        max-height: 200px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.9em;
        width: 100%;
        max-width: 200px;
    }
}

/* モバイル用テーブルスタイル */
@media (max-width: 480px) {
    .stock-card {
        padding: 12px;
    }
    
    .data-section {
        padding: 10px;
    }
    
    .data-row {
        padding: 8px 0;
    }
    
    .stock-chart {
        height: 180px !important;
    }
    
    header h1 {
        font-size: 1.5em;
    }
    
    .stock-name {
        font-size: 1.2em;
    }
}

/* スクロールバーのスタイリング（ダークモード） */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(20, 20, 30, 0.5);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.7);
}

/* デフォルト（デスクトップ）: デスクトップレイアウトを表示、モバイルテーブルを非表示 */
.mobile-table {
    display: none !important;
}

.desktop-layout {
    display: block !important;
}

/* デスクトップでは確実にデスクトップレイアウトを表示 */
@media (min-width: 769px) {
    .desktop-stocks-grid {
        display: grid !important;
    }
    
    .mobile-unified-sections {
        display: none !important;
    }
    
    .mobile-table {
        display: none !important;
    }
    
    .desktop-layout {
        display: block !important;
    }
    
    .desktop-layout .data-section {
        display: block !important;
    }
}

/* 統合テーブルセクション（モバイル用） */
.unified-table-section {
    padding: 15px;
    background: rgba(20, 20, 30, 0.8);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 15px;
}

.section-header {
    margin-top: 20px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.4);
}

.section-header:first-child {
    margin-top: 0;
}

.section-title {
    font-size: 1.1em;
    color: #667eea;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.unified-table-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.unified-cell {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: rgba(10, 10, 20, 0.6);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.2s ease;
}

.unified-cell:hover {
    background: rgba(10, 10, 20, 0.8);
    border-color: rgba(102, 126, 234, 0.3);
}

.cell-label {
    font-size: 0.75em;
    color: #a0a0a0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cell-value {
    font-size: 1.05em;
    color: #e0e0e0;
    font-weight: 700;
}

.cell-value.positive {
    color: #ef4444;
}

.cell-value.negative {
    color: #3b82f6;
}

.cell-value.neutral {
    color: #94a3b8;
}

/* 旧テーブルスタイル（後方互換性のため保持） */
.table-section {
    margin-bottom: 15px;
    padding: 12px;
    background: rgba(20, 20, 30, 0.6);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.table-title {
    font-size: 1em;
    color: #667eea;
    margin-bottom: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(102, 126, 234, 0.3);
}

.table-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.table-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .stocks-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    header {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .stock-card {
        padding: 15px;
        border-radius: 12px;
    }
    
    .stock-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 12px;
        padding-bottom: 12px;
    }
    
    .stock-name {
        font-size: 1.3em;
    }
    
    .stock-code {
        font-size: 0.9em;
    }
    
    /* モバイルではセクションごとの統合レイアウトを表示 */
    .desktop-stocks-grid {
        display: none !important;
    }
    
    .mobile-unified-sections {
        display: block !important;
    }
    
    .mobile-table {
        display: none !important;
    }
    
    .desktop-layout {
        display: none !important;
    }
    
    .section-box {
        margin-bottom: 15px;
        padding: 15px;
    }
    
    .section-box-title {
        font-size: 1.3em;
        margin-bottom: 15px;
    }
    
    .stocks-comparison-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stock-comparison-card {
        padding: 12px;
    }
    
    .comparison-stock-name {
        font-size: 1.1em;
    }
    
    .comparison-row {
        padding: 6px 0;
    }
    
    /* モバイル用: 要約セクション */
    .summary-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .summary-card {
        padding: 12px;
    }
    
    .summary-stock-name {
        font-size: 1.1em;
    }
    
    .summary-row {
        padding: 6px 0;
    }
    
    .summary-label {
        font-size: 0.8em;
    }
    
    .summary-value {
        font-size: 0.95em;
    }
    
    .comparison-label {
        font-size: 0.8em;
    }
    
    .comparison-value {
        font-size: 0.95em;
    }
    
    /* モバイル用チャート */
    .charts-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .mobile-chart-card {
        padding: 12px !important;
    }
    
    .mobile-chart-container {
        height: 220px !important;
    }
    
    .mobile-stock-chart {
        height: 220px !important;
        max-height: 220px !important;
    }
    
    .chart-header {
        margin-bottom: 12px !important;
    }
    
    .chart-stock-name {
        font-size: 1.1em !important;
    }
    
    /* モバイルでの基本スタイルを確実に適用 */
    .unified-table-section {
        display: block !important;
        padding: 15px !important;
        background: rgba(20, 20, 30, 0.8) !important;
        border-radius: 12px !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        margin-bottom: 15px !important;
    }
    
    .unified-table-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        margin-bottom: 15px !important;
    }
    
    .unified-cell {
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
        padding: 10px !important;
        background: rgba(10, 10, 20, 0.6) !important;
        border-radius: 8px !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
    }
    
    .section-header {
        display: block !important;
        margin-top: 20px !important;
        margin-bottom: 12px !important;
        padding-bottom: 8px !important;
        border-bottom: 2px solid rgba(102, 126, 234, 0.4) !important;
    }
    
    .section-header:first-child {
        margin-top: 0 !important;
    }
    
    .section-title {
        display: block !important;
        font-size: 1.1em !important;
        color: #667eea !important;
        font-weight: 700 !important;
        text-transform: uppercase !important;
        letter-spacing: 1px !important;
        margin: 0 !important;
    }
    
    .cell-label {
        display: block !important;
        font-size: 0.75em !important;
        color: #a0a0a0 !important;
        font-weight: 600 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
    }
    
    .cell-value {
        display: block !important;
        font-size: 1.05em !important;
        color: #e0e0e0 !important;
        font-weight: 700 !important;
    }
    
    .cell-value.positive {
        color: #ef4444 !important;
    }
    
    .cell-value.negative {
        color: #3b82f6 !important;
    }
    
    .unified-table-section {
        padding: 12px;
    }
    
    .section-header {
        margin-top: 15px;
        margin-bottom: 10px;
    }
    
    .section-title {
        font-size: 1em;
    }
    
    .unified-table-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .unified-cell {
        padding: 8px;
    }
    
    .cell-label {
        font-size: 0.7em;
    }
    
    .cell-value {
        font-size: 0.95em;
    }
    
    .chart-section {
        padding: 12px;
        margin-top: 15px;
    }
    
    .chart-section h3 {
        font-size: 0.95em;
    }
    
    .stock-chart {
        height: 200px !important;
        max-height: 200px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.9em;
        width: 100%;
        max-width: 200px;
    }
    
    .timestamp {
        margin-top: 12px;
        padding-top: 12px;
        font-size: 0.8em;
    }
}

/* 小さなモバイル用 */
@media (max-width: 480px) {
    .stock-card {
        padding: 12px;
    }
    
    .unified-table-section {
        padding: 10px;
    }
    
    .unified-table-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .unified-cell {
        padding: 10px;
    }
    
    .cell-label {
        font-size: 0.7em;
    }
    
    .cell-value {
        font-size: 1.05em;
    }
    
    .stock-chart {
        height: 180px !important;
    }
    
    header h1 {
        font-size: 1.5em;
    }
    
    .stock-name {
        font-size: 1.2em;
    }
    
    .section-title {
        font-size: 0.95em;
    }
}
