@charset "UTF-8";
/* Updated: 2026-02-10 14:00 - Final Consistent Design */
:root {
    --primary: #2c3e50; --success: #059669; --warning: #eab308; --danger: #ef4444;
    --background: #f8fafc; --border: #e2e8f0; --text-main: #334155; --text-muted: #64748b;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background-color: var(--background); color: var(--text-main); line-height: 1.6; }
.container-fluid { padding: 0 1rem; }
.navbar { background: #1a202c; color: white; padding: 1rem; }

.dashboard { background: white; border-radius: 12px; padding: 1.5rem; box-shadow: 0 4px 15px rgba(0,0,0,0.05); margin-top: 1rem; }
.section-header h2 {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #334155;
    margin: 0;
}
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.card { background: var(--primary); color: white; padding: 1.25rem; border-radius: 10px; }
.big-number { font-size: 2.2rem; font-weight: 800; }
.text-muted-light { color: rgba(255,255,255,0.7) !important; font-size: 0.75rem; }
.progress { height: 6px; background: rgba(255,255,255,0.2); border-radius: 3px; margin: 0.75rem 0; }
.progress-bar { height: 100%; background: white; }

/* Compact Obi Badges */
.signal-badge {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 0.38rem 0.5rem; border-radius: 6px; font-size: 0.8rem; color: white !important;
    text-align: center; width: auto; min-width: 140px; max-width: 200px; margin: 0 auto;
    min-height: 2.3rem; line-height: 1.12; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.signal-strong_buy { background: linear-gradient(135deg, #3b82f6, #2563eb); } /* Blue */
.signal-buy        { background: linear-gradient(135deg, #10b981, #059669); } /* Green */
.signal-hold       { background: #94a3b8; }                                   /* Gray */
.signal-warning    { background: linear-gradient(135deg, #fde047, #facc15); color: #422006 !important; } /* Yellow */
.signal-sell       { background: linear-gradient(135deg, #f97316, #ea580c); } /* Orange */
.signal-strong_sell { background: linear-gradient(135deg, #ef4444, #dc2626); } /* Red */

.badge-reason {
    font-size: 0.68rem;
    font-weight: normal;
    margin-top: 2px;
    opacity: 0.95;
    width: 100%;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}
.strategy-cell {
    text-align: left;
    vertical-align: middle;
    padding-left: 0.4rem !important;
    padding-right: 0.4rem !important;
}
.strategy-col {
    text-align: left !important;
}
.dashboard .data-table th.strategy-col,
.dashboard .data-table td.strategy-cell {
    width: auto;
    min-width: 200px;
    text-align: left;
    vertical-align: middle;
}
.strategy-cell .signal-badge {
    margin-left: 0;
    margin-right: 0;
    width: auto !important;
    min-width: 140px !important;
    max-width: 200px !important;
}

/* Table */
.data-table { width: 100%; border-collapse: collapse; margin-top: 1rem; table-layout: fixed; }
.data-table th { background: #f7fafc; padding: 0.75rem 0.85rem; text-align: left; font-weight: 700; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.data-table td { padding: 0.75rem 0.85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.footprint-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 140px;
    max-width: 200px;
    min-height: 2.6rem;
    padding: 0.38rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.12;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #edf2f7;
    color: #4a5568;
    border: 1px solid var(--border);
}

/* 列間余白の均等化（PC） */
.holdings-table td:nth-child(3) { padding-right: 1.45rem; } /* 機関 */
.holdings-table td:nth-child(4) { padding-left: 1.45rem; }  /* 取得/数量 */

.watchlist-table td:nth-child(3) { padding-right: 1.2rem; } /* 機関 */
.watchlist-table td:nth-child(4) { padding-left: 0.85rem; }  /* 戦略 */
.watchlist-table td:nth-child(5) { padding-left: 0.85rem; }  /* EV/RR */
.watchlist-table th:nth-child(4) { padding-left: 0.85rem; }  /* 戦略ヘッダ */
.watchlist-table th:nth-child(5) { padding-left: 0.85rem; }  /* EV/RRヘッダ */
.fp-accumulation { background-color: #eff6ff !important; color: #2563eb !important; border-color: #bfdbfe !important; }
.fp-strong_uptrend_leaving_poc { background-color: #f0f9ff !important; color: #0284c7 !important; border-color: #bae6fd !important; }
.fp-distribution { background-color: #fef2f2 !important; color: #dc2626 !important; border-color: #fecaca !important; }
.fp-strong_downtrend_leaving_poc { background-color: #fee2e2 !important; color: #b91c1c !important; border-color: #fca5a5 !important; }
.fp-absorption { background-color: #f0fdf4 !important; color: #15803d !important; border-color: #bbf7d0 !important; }
.fp-neutral { background-color: #f1f5f9 !important; color: #94a3b8 !important; }
.fp-unknown { background-color: #f1f5f9 !important; color: #94a3b8 !important; border-color: #e2e8f0 !important; }
.positive { color: var(--success); font-weight: 700; }
.negative { color: var(--danger); font-weight: 700; }

/* Manage page form layout */
.manage-page .card {
    background: var(--primary) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}
.ticker-cell {
    display: flex;
    flex-direction: column;
    gap: 0;
    line-height: 1.05;
}
.ticker-cell .ticker-symbol {
    margin: 0;
}
.ticker-cell .ticker-sector {
    margin: 0;
    line-height: 1.05;
}
.stock-form .vertical-stack {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
}
.stock-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.stock-form .form-group label {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.85);
    font-weight: 700;
}
.stock-form .form-group input,
.form-control-inline {
    width: 100%;
    min-width: 0;
    padding: 0.55rem 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #f8fafc;
    color: #1f2937;
}
.form-control-inline {
    max-width: 130px;
}

/* Desktop column balance via colgroup */
.dashboard .holdings-table col.col-ticker { width: 14%; }
.dashboard .holdings-table col.col-price { width: 14%; }
.dashboard .holdings-table col.col-inst { width: 12%; }
.dashboard .holdings-table col.col-acq { width: 14%; }
.dashboard .holdings-table col.col-pnl { width: 14%; }
.dashboard .holdings-table col.col-strategy { width: 19%; }
.dashboard .holdings-table col.col-ev { width: 13%; }

.dashboard .watchlist-table col.col-ticker { width: 14%; }
.dashboard .watchlist-table col.col-price { width: 14%; }
.dashboard .watchlist-table col.col-inst { width: 40%; }
.dashboard .watchlist-table col.col-strategy { width: 19%; }
.dashboard .watchlist-table col.col-ev { width: 13%; }

/* PCのみ: 保有テーブルの 価格/前日比〜含み損益 を約1cm右へ */
@media (min-width: 993px) {
    .holdings-table th:nth-child(2),
    .holdings-table th:nth-child(3),
    .holdings-table th:nth-child(4),
    .holdings-table th:nth-child(5),
    .holdings-table td:nth-child(2),
    .holdings-table td:nth-child(3),
    .holdings-table td:nth-child(4),
    .holdings-table td:nth-child(5) {
        padding-left: 3.25rem;
    }
    /* 含み損益(5列目)のみ約1cm戻す */
    .holdings-table th:nth-child(5),
    .holdings-table td:nth-child(5) {
        padding-left: 0.85rem !important;
    }
    /* 指定調整: 取得/数量を約1cm右、含み損益を約0.5mm右 */
    .holdings-table th:nth-child(4),
    .holdings-table td:nth-child(4) {
        padding-left: 5.00rem !important;
    }
    .holdings-table th:nth-child(5),
    .holdings-table td:nth-child(5) {
        padding-left: 2.20rem !important;
    }
    /* 機関ブロック大型化に伴う微調整: 列3を僅かに左へ */
    .holdings-table th:nth-child(3),
    .holdings-table td:nth-child(3),
    .watchlist-table th:nth-child(3),
    .watchlist-table td:nth-child(3) {
        padding-left: 2.95rem !important;
    }

    /* 監視テーブルも保有テーブルと開始位置を揃える */
    .watchlist-table th:nth-child(2),
    .watchlist-table td:nth-child(2) {
        padding-left: 3.25rem !important; /* 価格/前日比 */
    }
    .watchlist-table th:nth-child(3),
    .watchlist-table td:nth-child(3) {
        padding-left: 3.25rem !important; /* 機関 */
    }
}

@media (max-width: 992px) {
    /* モバイルではテーブルをカード化し、幅縮みを禁止 */
    .data-table,
    .data-table tbody {
        display: block;
        width: 100% !important;
    }
    .data-table colgroup {
        display: none !important;
    }
    /* PC向けの列別オフセットをモバイルでは無効化 */
    .holdings-table th,
    .holdings-table td,
    .watchlist-table th,
    .watchlist-table td {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    .data-table {
        table-layout: auto;
    }
    .dashboard {
        padding: 1rem;
    }
    .summary-cards {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    .big-number {
        font-size: 1.8rem;
    }
    .section-header h2 {
        font-size: 1.7rem;
    }
    .signal-badge {
        min-width: 0;
        max-width: 100%;
        width: 100%;
        min-height: 2.1rem;
        padding: 0.3rem 0.45rem;
    }
    .badge-reason {
        font-size: 0.68rem;
        line-height: 1.2;
    }
    .stock-form .vertical-stack {
        grid-template-columns: 1fr;
    }
    .form-control-inline {
        max-width: 100%;
    }
    .dashboard .data-table th.strategy-col,
    .dashboard .data-table td.strategy-cell {
        width: auto;
        min-width: 0;
    }
    .data-table th { display: none; }
    .data-table tr {
        display: block;
        width: 100% !important;
        border: 1px solid var(--border);
        margin-bottom: 1rem;
        border-radius: 10px;
        overflow: hidden;
    }

    /* 基本: モバイルは2カラム固定（左:ラベル / 右:値） */
    .data-table td {
        display: grid;
        grid-template-columns: 5.8rem minmax(0, 1fr);
        column-gap: 0.65rem;
        align-items: center;
        border: none;
        border-bottom: 1px solid #f7fafc;
        padding: 0.8rem 1rem !important;
        text-align: right;
    }
    .data-table td:before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
        text-align: left;
        white-space: nowrap;
        word-break: keep-all;
        line-height: 1.2;
        padding-top: 0.05rem;
    }
    .data-table td > * {
        min-width: 0;
        justify-self: end;
        text-align: right;
    }
    .metric-main {
        display: inline-block;
        min-width: 8.2rem;
        text-align: right;
        font-variant-numeric: tabular-nums;
        font-feature-settings: "tnum" 1;
        white-space: nowrap;
    }

    /* 戦略セルだけ左寄せ（他と同じ2カラムを維持） */
    .data-table td.strategy-cell {
        display: grid !important;
        grid-template-columns: 5.8rem minmax(0, 1fr) !important;
        align-items: center !important;
        text-align: left !important;
        padding-left: 1rem !important;
    }
    .data-table td.strategy-cell:before {
        margin-bottom: 0 !important;
    }
    .data-table td.strategy-cell .signal-badge {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        text-align: center !important;
        align-items: center !important;
        justify-self: end !important;
        border: 1px solid var(--border) !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
        height: 2.6rem !important;
        min-height: 2.6rem !important;
        max-height: 2.6rem !important;
        padding: 0.3rem 0.45rem !important;
        overflow: hidden !important;
    }
    .data-table td.strategy-cell .signal-badge strong {
        display: block !important;
        font-size: 0.82rem !important;
        line-height: 1.1 !important;
        text-align: center !important;
        white-space: nowrap !important;
    }
    .data-table td.strategy-cell .signal-badge .badge-reason {
        display: block !important;
        font-size: 0.68rem !important;
        line-height: 1.1 !important;
        margin-top: 1px !important;
        opacity: 0.95 !important;
        white-space: nowrap !important;
    }

    /* 戦略セル内の文字は常に横書きに固定 */
    .data-table td.strategy-cell,
    .data-table td.strategy-cell * {
        writing-mode: horizontal-tb !important;
        white-space: normal;
    }

    /* 価格/比は1列表示（ラベル上・値下） */
    .data-table td.price-cell {
        display: grid !important;
        grid-template-columns: 5.8rem minmax(0, 1fr) !important;
        text-align: right !important;
    }
    .data-table td.price-cell:before {
        display: block !important;
        margin-bottom: 0 !important;
    }
    .data-table td.price-cell .price-inline {
        grid-column: 2;
        justify-self: end;
        text-align: right;
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
        font-feature-settings: "tnum" 1;
    }
    /* 旧テンプレート構造互換: price-inline未適用でも右列固定 */
    .data-table td.price-cell > .price-main,
    .data-table td.price-cell > small {
        grid-column: 2 !important;
        justify-self: end !important;
        text-align: right !important;
        white-space: nowrap !important;
    }
    .data-table td.price-cell .price-main {
        display: inline;
        margin-bottom: 0;
    }
    .data-table td.price-cell small {
        display: inline;
        margin-left: 0;
        white-space: nowrap;
    }
    .data-table td:first-child {
        display: block !important;
        background: #f8fafc;
        font-size: 1.05rem;
        border-bottom: 2px solid var(--border);
        padding: 0.8rem 1rem !important;
    }
    .ticker-cell {
        width: 100%;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0.75rem;
    }
    .ticker-cell .ticker-symbol {
        font-size: 1.05rem;
    }
    .ticker-cell .ticker-sector {
        font-size: 0.82rem;
        color: var(--text-muted);
        text-align: right;
        white-space: nowrap;
    }
    .data-table td:first-child:before {
        content: "";
        display: none;
    }

    /* 機関バッジを戦略バッジと同じ幅運用に統一 */
    .data-table td .footprint-badge {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: 2.6rem !important;
        min-height: 2.6rem !important;
        max-height: 2.6rem !important;
        padding: 0.3rem 0.45rem;
        border-radius: 6px;
        font-size: 0.8rem;
        line-height: 1.12;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        border: 1px solid var(--border) !important;
        justify-self: end;
        text-align: center;
        white-space: normal;
        word-break: keep-all;
    }
}
