body {
    min-height: 100vh;
    padding-top: 56px;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ダークテーマ用のスタイル */
[data-bs-theme="dark"] body {
    background-color: #212529;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .card {
    background-color: #343a40;
    border-color: #495057;
}

[data-bs-theme="dark"] .card-header {
    background-color: #2c3136;
    border-color: #495057;
}

[data-bs-theme="dark"] .list-group-item {
    background-color: #343a40;
    border-color: #495057;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .text-muted {
    color: #adb5bd !important;
}

[data-bs-theme="dark"] .form-control {
    background-color: #2c3136;
    border-color: #495057;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .form-control:focus {
    background-color: #2c3136;
    border-color: #6c757d;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .btn-outline-secondary {
    color: #f8f9fa;
    border-color: #6c757d;
}

[data-bs-theme="dark"] .btn-outline-secondary:hover {
    background-color: #6c757d;
    color: #f8f9fa;
}

@media (min-width: 768px) {
    body {
        padding-top: 60px;
    }
}

/* サイドバー関連のスタイル */
.sidebar {
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 0;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    background-color: var(--bs-body-bg);
    overflow-y: auto;
    transition: all 0.3s;
    width: 250px;
}

.sidebar-sticky {
    position: relative;
    top: 0;
    height: calc(100vh - 56px);
    padding-top: 1rem;
    overflow-x: hidden;
    overflow-y: auto;
}

.sidebar .nav-link {
    font-weight: 500;
    color: var(--bs-body-color);
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.sidebar .nav-link:hover {
    color: var(--bs-primary);
    background-color: rgba(var(--bs-primary-rgb), 0.1);
}

.sidebar .nav-link.active {
    color: var(--bs-primary);
    background-color: rgba(var(--bs-primary-rgb), 0.1);
}

.sidebar .nav-link i {
    margin-right: 0.5rem;
}

.sidebar-heading {
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* メインコンテンツのスタイル */
.main-content {
    margin-left: 250px;
    padding: 1.5rem;
    width: calc(100% - 250px);
    transition: all 0.3s;
}

/* サイドバーを閉じるボタンのスタイル */
#sidebarCollapse {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--bs-body-color);
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

#sidebarCollapse:hover {
    color: var(--bs-primary);
}

/* サイドバーの切り替え状態 (PC: アイコンのみ) */
#sidebar.active {
    width: 60px;
}

#sidebar.active .nav-text {
    display: none;
}

#sidebar.active .sidebar-heading {
    visibility: hidden;
}

#sidebar.active .nav-link {
    justify-content: center;
    padding: 0.75rem;
}

#sidebar.active .nav-link i {
    margin-right: 0;
    font-size: 1.2rem;
}

.main-content.active {
    margin-left: 60px;
    width: calc(100% - 60px);
}

/* オーバーレイ */
.overlay {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.overlay.active {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {
    .sidebar {
        margin-left: -100%;
        width: 100%;
    }
    #sidebar.active,
    .sidebar.active {
        margin-left: 0;
        width: 100%;
    }
    #sidebar.active .nav-text {
        display: inline;
    }
    #sidebar.active .sidebar-heading {
        visibility: visible;
    }
    #sidebar.active .nav-link {
        justify-content: flex-start;
        padding: 0.75rem 1.25rem;
        font-size: 1rem;
    }
    #sidebar.active .nav-link i {
        margin-right: 0.75rem;
        font-size: 1.1rem;
    }
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    .main-content.active {
        margin-left: 0;
        width: 100%;
    }
}

/* モバイル用サイドバー閉じるボタン */
.sidebar-close-btn {
    display: flex;
    justify-content: flex-end;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .sidebar-close-btn {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* ダークテーマ用のスタイル */
[data-bs-theme="dark"] .sidebar {
    background-color: var(--bs-dark);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .sidebar .nav-link {
    color: var(--bs-light);
}

[data-bs-theme="dark"] .sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .sidebar-heading {
    color: var(--bs-secondary-color);
}

[data-bs-theme="dark"] .overlay {
    background: rgba(0, 0, 0, 0.7);
}

/* 担当工程テーブル: 列に最小幅を設定して横スクロールを有効化 */
.table-phases th,
.table-phases td {
    min-width: 4.5rem;
    white-space: nowrap;
}

/* モバイル: キーバリューテーブルを縦積み表示 */
@media (max-width: 575.98px) {
    .table-key-value,
    .table-key-value tbody,
    .table-key-value tr,
    .table-key-value th,
    .table-key-value td {
        display: block;
    }
    .table-key-value tr {
        border-bottom: 1px solid var(--bs-border-color);
        padding: 0.4rem 0;
    }
    .table-key-value th {
        width: 100% !important;
        border: none;
        padding: 0 0.75rem 0.1rem;
        font-size: 0.78rem;
        color: var(--bs-secondary-color);
        background: transparent !important;
    }
    .table-key-value td {
        width: 100%;
        border: none;
        padding: 0 0.75rem 0.1rem;
    }
}