/* 基本スタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* ヘッダー */
header {
    background: #1a73e8;
    color: white;
    padding: 0.5rem 1rem;
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-links a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 0.5rem;
}

.nav-links a:hover {
    color: white;
}

/* メイン */
main {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

.container {
    padding: 0;
}

/* ページヘッダー */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

h1 {
    font-size: 1.5rem;
    color: #333;
}

h2 {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 1rem;
}

/* カード */
.card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ボタン */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-primary {
    background: #1a73e8;
    color: white;
}

.btn-secondary {
    background: #e53935;
    color: white;
}

.btn-back {
    background: #757575;
    color: white;
}

.btn-large {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
}

.btn:hover {
    opacity: 0.9;
}

/* アクションボタン */
.actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.actions .btn {
    flex: 1;
    text-align: center;
}

/* サマリー */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

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

.summary-item.total {
    grid-column: 1 / -1;
    padding-top: 0.75rem;
    border-top: 1px solid #eee;
}

.summary-item .label {
    font-size: 0.8rem;
    color: #666;
}

.summary-item .value {
    font-size: 1.1rem;
    font-weight: bold;
}

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

.summary-inline .label {
    color: #666;
}

.summary-inline .value {
    font-size: 1.2rem;
    font-weight: bold;
}

/* 損益カラー */
.profit {
    color: #2e7d32;
}

.loss {
    color: #c62828;
}

/* ポジション一覧 */
.positions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.position-card {
    padding: 0.75rem;
    border: 1px solid #eee;
    border-radius: 6px;
}

.position-header {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.position-ticker {
    font-weight: normal;
    color: #666;
    font-size: 0.9rem;
}

.position-detail {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.position-current {
    font-size: 0.9rem;
}

.position-current .pnl {
    font-weight: bold;
}

/* シグナル・ポジション選択 */
.signal-list,
.position-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.signal-item,
.position-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 2px solid #eee;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.signal-item:has(input:checked),
.position-item:has(input:checked) {
    border-color: #1a73e8;
    background: #f8faff;
}

.position-item.recommended {
    border-color: #ffcdd2;
    background: #fff8f8;
}

.position-item.recommended:has(input:checked) {
    border-color: #e53935;
}

.signal-item input,
.position-item input {
    margin-top: 0.25rem;
}

.signal-content,
.position-content {
    flex: 1;
}

.signal-header,
.position-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.signal-name,
.position-name {
    font-weight: bold;
}

.signal-ticker,
.position-ticker {
    color: #666;
    font-size: 0.9rem;
}

.signal-detail {
    margin-top: 0.25rem;
    font-size: 0.9rem;
}

.signal-reason {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: #666;
}

.position-pnl {
    margin-top: 0.25rem;
    font-weight: bold;
}

/* 確信度 */
.confidence {
    font-size: 0.9rem;
}

.confidence-high {
    color: #2e7d32;
}

.confidence-medium {
    color: #f57c00;
}

.confidence-low {
    color: #666;
}

/* バッジ */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: bold;
}

.badge-buy {
    background: #e3f2fd;
    color: #1565c0;
}

.badge-sell {
    background: #ffebee;
    color: #c62828;
}

.badge-short {
    background: #ffcdd2;
    color: #c62828;
}

.badge-long {
    background: #e3f2fd;
    color: #1565c0;
}

/* タブ */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab {
    flex: 1;
    text-align: center;
    padding: 0.75rem 1rem;
    background: #e0e0e0;
    color: #666;
    text-decoration: none;
    border-radius: 6px 6px 0 0;
    font-weight: 500;
    transition: all 0.2s;
}

.tab:hover {
    background: #d0d0d0;
}

.tab.active {
    background: white;
    color: #1a73e8;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.05);
}

.tab .count {
    display: inline-block;
    background: #1a73e8;
    color: white;
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    margin-left: 0.25rem;
}

.tab.active .count {
    background: #1a73e8;
}

/* 空売りボタン */
.btn-short {
    background: #ff7043;
    color: white;
}

/* 空売りシグナル */
.signal-item.short-signal {
    border-color: #ffccbc;
    background: #fff8f6;
}

.signal-item.short-signal:has(input:checked) {
    border-color: #ff7043;
    background: #fff3e0;
}

/* 空売りポジション */
.position-card.short-position {
    border-color: #ffccbc;
    background: #fff8f6;
}

/* 買戻し推奨 */
.position-item.recommended-cover {
    border-color: #c8e6c9;
    background: #f1f8e9;
}

.position-item.recommended-cover:has(input:checked) {
    border-color: #4caf50;
}

/* フォーム */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 0.25rem;
}

.form-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: #1a73e8;
}

.form-group .hint {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
}

.total-display {
    background: #f5f5f5;
    padding: 0.75rem;
    border-radius: 4px;
}

.total-value {
    font-size: 1.2rem;
    font-weight: bold;
}

/* テーブル */
.trades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.trades-table th,
.trades-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.trades-table th {
    font-weight: 600;
    color: #555;
    background: #fafafa;
}

.trades-table .date {
    white-space: nowrap;
    font-size: 0.8rem;
    color: #666;
}

.trades-table .ticker-code {
    font-size: 0.8rem;
    color: #999;
}

.trades-table .quantity,
.trades-table .price,
.trades-table .amount {
    text-align: right;
}

.trades-table .pnl {
    text-align: right;
    font-weight: bold;
}

/* ページネーション */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.page-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #1a73e8;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
}

.page-btn:hover {
    background: #1557b0;
}

.page-info {
    color: #666;
    font-size: 0.9rem;
}

/* 空状態 */
.empty {
    text-align: center;
    color: #999;
    padding: 2rem;
}

/* フッター */
footer {
    text-align: center;
    padding: 1rem;
    color: #999;
    font-size: 0.8rem;
}

/* ユーザー情報 */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-name {
    font-size: 0.9rem;
}

.btn-logout {
    padding: 0.3rem 0.6rem;
    background: rgba(255,255,255,0.2);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.85rem;
}

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

/* 認証ページ */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-card {
    max-width: 400px;
    width: 100%;
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.auth-link {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #666;
}

.auth-link a {
    color: #1a73e8;
}

/* レスポンシブ */
@media (max-width: 600px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .actions {
        flex-direction: column;
    }

    .trades-table {
        font-size: 0.8rem;
    }

    .trades-table th,
    .trades-table td {
        padding: 0.4rem;
    }

    .user-info {
        display: none;
    }
}
